String là viết tắt của System.String, trong khi string là alias (bí danh) trong C# cho System.String.
Ví dụ:
string str = "Welcome!";
Thường dùng String khi làm việc với lớp:
string str = String.Format("Welcome! {0}!", user);
Vì string là alias của System.String. Các alias khác:
object: System.Object string: System.String bool: System.Boolean float: System.Single double: System.Double decimal: System.Decimal byte: System.Byte sbyte: System.SByte short: System.Int16 ushort: System.UInt16 int: System.Int32 uint: System.UInt32 long: System.Int64 ulong: System.UInt64 char: System.Char
Kiểu String cho phép gán giá trị chuỗi. Dùng string literal hai dạng: quoted và @quoted.
Ví dụ
String str = "Okay!";