Saturday, April 2, 2011

Difference between string and String

Good morning friends,
This is a common question which comes to programmers' minds.
Difference between string and String, bool and Bool etc.
The answer is quite simple; string is an alias (another name) for String (here String is System.String)
similarly, bool is alias and Bool is CLR type.
Following are some more examples:

shortSystem.Int16
ushortSystem.UInt16
intSystem.Int32
uintSystem.UInt32
longSystem.Int64
ulongSystem.UInt64




They can be used interchangeably, but there is only one circumstance where you need to uses aliases and not the CLR type. While explicitly specifying the datatype for enum.
e.g., public enum Color : int


here Int32 would be invalid to use.


Hope this is helpful.

1 comment:

Aashita said...

thanku javed....

ur valuable info helped me a lot..
infact its jus a life saver.............

garvita