Quantcast
Viewing all articles
Browse latest Browse all 69

Answer by BanksySan for What is the difference between String and string in C#?

There is one practical difference between string and String.

nameof(String); // compilesnameof(string); // doesn't compile

This is because string is a keyword (an alias in this case) whereas String is a type.

The same is true for the other aliases as well.

| Alias     | Type             ||-----------|------------------||  bool     |  System.Boolean  ||  byte     |  System.Byte     ||  sbyte    |  System.SByte    ||  char     |  System.Char     ||  decimal  |  System.Decimal  ||  double   |  System.Double   ||  float    |  System.Single   ||  int      |  System.Int32    ||  uint     |  System.UInt32   ||  long     |  System.Int64    ||  ulong    |  System.UInt64   ||  object   |  System.Object   ||  short    |  System.Int16    ||  ushort   |  System.UInt16   ||  string   |  System.String   |

Viewing all articles
Browse latest Browse all 69

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>