So I'm obviously fairly new to programming, but am trying to figure out why this isn't working
I'm trying to take the string myname, and add Mr. to the start of it. I know I could do it simply as just myname = "Mr. " + myname however I'm trying to understand how to use methods to change the values of variables. So, why doesn't this change?
public class Program { public static void Main(string[] args) { string myname = "harry"; Console.WriteLine(myname); //output is harry namechanger(myname); //this should modify harry to Mr. Harry Console.WriteLine(myname); //output is still harry? } static string namechanger(string name) { name = "Mr. " + name; return name; } }