V
vincente13
i understand that in csharp "string" and "object" are reference type...
For e.g. in this case
myString is passed to a method and it changes the value of the string..
if string is a reference type, isnt it passed to the method by
reference and the second WriteLine should be "edited" instead of "hello
world" ?
String myString = "hello world";
Console.WriteLine("String before function : " + myString);
doSomethingToString(myString);
Console.WriteLine("String afer function : " + myString);
static void doSomethingToString(string myString)
{
myString = "edited";
}
For e.g. in this case
myString is passed to a method and it changes the value of the string..
if string is a reference type, isnt it passed to the method by
reference and the second WriteLine should be "edited" instead of "hello
world" ?
String myString = "hello world";
Console.WriteLine("String before function : " + myString);
doSomethingToString(myString);
Console.WriteLine("String afer function : " + myString);
static void doSomethingToString(string myString)
{
myString = "edited";
}