Java vs. C#

String vs. string


Java
 
String is a reference type but immutable.
for example,(Note: the Upper-calse S for String)

String s1 = "hello";
String s2 = s1; 
s1 = "goodbye";
System.out.println(s2);//hello
System.out.println(s1);//goodbye

string path = "C:\\My Documents\\"; There is no verbatim string in Java

C#
 
string is a reference type but immutable.
for example,(Note: the lower-case s for string)

string s1 = "hello";
string s2 = s1; 
s1 = "goodbye";
System.Console.WriteLine(s2);//hello
System.Console.WriteLine(s1);//goodbye

string path = "C:\\My Documents\\"; can be written with verbatim string like: string path = @"C:\My Documents\";