I have a DependencyObject in C# that is used in an array. Example shown below:
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 }}
How would I convert this code to VB.NET?
Thanks!
dummy's response was almost right, VB.Net's syntax has a "WITH" after the constructors.
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} _
}
就像是:
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 }}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.