String stands for System.String and it is a .NET Framework type. string is an alias in the C# language for System.String. Both of them are compiled to System.String in IL (Intermediate Language), so there is no difference. At execution time there is no difference. As far as guidelines, it's recommended to use string any time you're referring to an object.
Example:
Example:
Example:
It's generally recommended to use String if you need to refer specifically to the class.
- string place = "Hello World";
Example:
Similarly for other datatypes,
- var place = 'World!'
- string message = String.Format("Hello {0}!", place);
- object: System.Object
- string: System.String
- bool: System.Boolean
- byte: System.Byte
- sbyte: System.SByte
- short: System.Int16
- ushort: System.UInt16
- int: System.Int32
- uint: System.UInt32
- long: System.Int64
- ulong: System.UInt64
- float: System.Single
- double: System.Double
- decimal: System.Decimal
- char: System.Char
No comments:
Post a Comment