C# 與 VB 委派的分別..


基本上分別是在於 new Object() 和 new Object[] 的分別 = = 研究了很久才知道原來是這問題 …

C# :

1
2
3
4
5
6
7
8
9
public delegate void setListWaitLabelDelegate(string str);

private void getListServerXml() {
listWaitLabel.Invoke(new setListWaitLabelDelegate(this.setListWaiteLabel), new Object[] {"連線中"});
}

private void setListWaiteLabel(string str) {
listWaitLabel.Text = str;
}

VB.NET :

1
2
3
4
5
6
7
8
9
Private Delegate Sub setListWaitLabelDelegate(ByVal str As String);

private getListServerXml() {
listWaitLabel.Invoke(new setListWaitLabelDelegate(AddressOf setListWaiteLabel), new Object() {"連線中"});
}

private setListWaiteLabel(ByVal str As String) {
listWaitLabel.Text = str;
}