繁体   English   中英

DependencyObject Array C#至VB.NET

[英]DependencyObject Array C# to VB.NET

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

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?

谢谢!

dummy的响应几乎是正确的,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} _
    }

就像是:

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 }}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM