To be honest, in practice usually there is not difference between System.String
and string
.
All types in C# are objects and all derives from System.Object
class. One difference is that string is a C# keyword and String
you can use as variable name. System.String
is conventional .NET name of this type and string is convenient C# name. Here is simple program which presents difference between System.String
and string.
string a = new string(new char[] { 'x', 'y', 'z' });string b = new String(new char[] { 'x', 'y', 'z' });String c = new string(new char[] { 'x', 'y', 'z' });String d = new String(new char[] { 'x', 'y', 'z' });MessageBox.Show((a.GetType() == typeof(String) && a.GetType() == typeof(string)).ToString()); // shows trueMessageBox.Show((b.GetType() == typeof(String) && b.GetType() == typeof(string)).ToString()); // shows trueMessageBox.Show((c.GetType() == typeof(String) && c.GetType() == typeof(string)).ToString()); // shows trueMessageBox.Show((d.GetType() == typeof(String) && d.GetType() == typeof(string)).ToString()); // shows true
@JonSkeet in my compiler
public enum Foo : UInt32 { }
is working. I've Visual Studio 2015 Community.