2009-01-05 38 views
0

我有一个在数组中使用的C#中的DependencyObject。示例如下所示:DependencyObject Array C#VB.NET

private KeywordTag[] tags = new KeywordTag[] { 
    new KeywordTag { Tag = "test", IncidenceCount = 2076 }, 
    new KeywordTag { Tag = "oi", IncidenceCount = 2052 }, 
    new KeywordTag { Tag = "hmm", IncidenceCount = 1887 }, 
    new KeywordTag { Tag = "grr", IncidenceCount = 1414 }, 
    new KeywordTag { Tag = "thanks", IncidenceCount = 1166 }} 

如何将此代码转换为VB.NET?

谢谢!

回答

3

假人的反应是差不多吧,VB.Net的语法有一个构造函数 “WITH” 后。

Private tags() As KeywordTag = { _ 
    New KeywordTag() WITH {.Tag = test", .IncidentCount = 2076}, _ 
    New KeywordTag() WITH {.Tag = "oi", .IncidentCount = 2052}, _ 
    New KeywordTag() WITH {.Tag = "hmm", .IncidentCount = 1887}, _ 
    New KeywordTag() WITH {.Tag = "grr", .IncidentCount = 1414}, _ 
    New KeywordTag() WITH {.Tag = "thanks", .IncidentCount = 1166} _ 
    } 
+0

我打赌“标记”之前没有空白。但是这看起来更好,所以我删除了它。 – dummy 2009-01-05 14:26:58

2

喜欢的东西:

Private tags() As KeywordTag = { New KeywordTag { Tag = "test", IncidenceCount = 2076 }, New KeywordTag { Tag = "oi", IncidenceCount = 2052 }, New KeywordTag { Tag = "hmm", IncidenceCount = 1887 }, New KeywordTag { Tag = "grr", IncidenceCount = 1414 }, New KeywordTag { Tag = "thanks", IncidenceCount = 1166 }}