j*****o 发帖数: 320 | 1 Class是Reference Type. 怎么才能只传递值?以一个简单的TextBox为例:
TextBox txtBox2 = new TextBox();
txtBox2.Text = "2";
TextBox txtBox3 = txtBox2 ;
txtBox3.Text = "3";
MessageBox.Show(txtBox2.Text); // 怎么才能够输出2?
谢谢! |
|
m******t 发帖数: 2416 | 2
You can't. By the fourth line above, txtBox2.Text is already "3".
Note txtBox3 is referencing the same object as txtBox2. This does
not have to do with passing by ref or value. |
|
j*****o 发帖数: 320 | 3 有什么办法在用txtBox2给txtBox3付值得时候,不传递txtBox2的reference, 而只是传递
txtBox2的值?
谢谢。 |
|
m******t 发帖数: 2416 | 4 I meant literally make another text box, and call it txtBox3. |
|