CSharp String Theory—string versus String

From C# Online.NET (CSharp-Online.NET)—your free C# and .NET encyclopedia


Jump to: navigation, search
CSharp-Online.NET:Articles
C# Articles

C# String Theory

edit

string versus String

If you are new to C#, you are probably wondering what the difference is between the string and String types. In the .NET framework, string is simply an alias—shorthand—for the Common Type System (CTS) System.String class which represents a sequence of characters. (string is one of two predefined C# reference types: The other is object.) You can use them interchangeably in your code.

String x = string.Copy ("x");
string y = String.Copy ("y");

Visual C# Best Practices

  • Use "String" to refer specifically to the String class.
  • Use "string" when referring to an object of the String class.


Previous_Page_.gif Next_Page_.gif

Personal tools
C# Entry Points