由买买提看人间百态

topics

全部话题 - 话题: txtbox3
(共0页)
j*****o
发帖数: 320
1
来自主题: DotNet版 - Reference type问题
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
来自主题: DotNet版 - Reference type问题

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
来自主题: DotNet版 - Reference type问题
有什么办法在用txtBox2给txtBox3付值得时候,不传递txtBox2的reference, 而只是传递
txtBox2的值?
谢谢。
m******t
发帖数: 2416
4
来自主题: DotNet版 - Reference type问题
I meant literally make another text box, and call it txtBox3.
(共0页)