Possible Duplicate:
In C#, why is String a reference type that behaves like a value type?
I know string is a reference type since string can be very large and stack is only 1 mb . But programatically while coding i see it behaves like value type for eg
string func_name(string streg)
{
streg="hello";
return streg;
}
-------------
string str="hi";
str= func_name(str);
now str gets the value hello ?
why so ? it bahaves exactly like value type here.
Because it was decided that the string
type would be immutable, but strings can still be very large.
You can read why here:
And another question similar to yours:
In C#, why is String a reference type that behaves like a value type?