2009-01-05 37 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 }}