Monday, March 12, 2012

what is the difference between String and string ?

first, i thought that String is reference-type and string is value-type, so I try:

String s;
s = "123";
String s2;
s2 = s;

s2 = "456";
MessageBox.Show(s);

but the result is not as good as i thought, it show "123", not "456"

so what is the difference between String and string ?There is no difference. string is just an c# alias for CLR type System.String, just like int is an alias for System.Int32

0 comments:

Post a Comment