如何在C#中编写Dim代码作为新的System.Windows.Forms.Binding("text",Me.bindingSource1,"ATMCode",True)

Ekk*_*yuk 3 c# vb.net

大家好怎么用C#编写这个VB源码

Dim codes As New System.Windows.Forms.Binding("text", Me.bindingSource1, "ATMCode", True)
Run Code Online (Sandbox Code Playgroud)

我试过写

int codes = new Binding("text", this.bindingSource1, "ATMCode", True);
Run Code Online (Sandbox Code Playgroud)

但VS表示错误无法将类型'System.Windows.Forms.Binding'隐式转换为'int'

Kev*_*vin 5

var codes = new Binding("text", this.bindingSource1, "ATMCode", true);
Run Code Online (Sandbox Code Playgroud)

上面代码的问题在于它是一个Binding而不是Int.

就像罗伯特说你也可以把它写成......

Binding codes = new Binding("text", this.bindingSource1, "ATMCode", true);
Run Code Online (Sandbox Code Playgroud)

如果你来自VB,这可能不那么令人困惑.