[英]C# to VB.NET syntax conversion for class instantiation with properties
I am working with Workflow Foundations 4 (in C#) and am trying to write a VB.NET expression. 我正在使用Workflow Foundations 4(在C#中)并且我正在尝试编写VB.NET表达式。 Is there a way to do the following in VB.NET on one line?
有没有办法在一行上的VB.NET中执行以下操作?
SomeObj instance = new SomeObj()
{
SomeStringProp = "a",
SomeIntProp = 17
};
Here's an example: 这是一个例子:
Dim instance = new SomeObj() With {
.ISomeStringProp = "a",
.SomeIntProp = 17
}
If you want more info take a look at VB.NET 9.0: Object and Array Initializers . 如果您想了解更多信息,请查看VB.NET 9.0:对象和数组初始化器 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.