Dim objConn As New Pclient.Connection
上面的命令为Pclient类创建新对象。但如何在C#
中做同样的事情它在VB中创建一个新对象,但是如何用C#
编写答案 0 :(得分:5)
var objConn = new Pclient.Connection();
或者您可以指定类型
Pclient.Connection objConn = new Pclient.Connection();
您可以尝试
等在线转换器并且您还可以更好地了解Initialize Objects by Using an Object Initializer
vb.net
Dim hero As New SuperHero
With hero
.Name = "SpamMan"
.PowerLevel = 3
End With
Dim hero As New superhero With {.Name = "SpamMan", .PowerLevel = 3}
<强> C#强>
SuperHero hero = new SuperHero() { Name = "SpamMan", PowerLevel = 3 };
的示例代码