Sunday, July 12, 2009

C# & visual studio, what is the difference between string & String?

from the point of view of writing programs there's not much difference.


The difference is where the two data types come from.


There are two types of data types in C#. One that is the part of language itself, and the other it borrows from Dot Net Common Language Infrastructure (CLI).


The data type "string" is a part of C# language definition. i.e. it is a valid type in C# only not in C++ dot net or anything.


Whereas, "String" is a part of CLI. i.e. it is valid type in all other language supporting Dot Net.


It's the same as in difference between "int" and "Int32"

C# %26amp; visual studio, what is the difference between string %26amp; String?
Actually, I'm pretty sure 'String' is the same thing as 'string' because you can use them interchangeably. The only other difference is that string gets a dark blue coloring while String gets a nice, pleasant aqua-blue coloring in the IDE, which is why I prefer it.
Reply:They are the same. string is an alias to String. To be more accurate, String is the name of the data type in the Framework. string is the keyword in C#.





This is similar to comparing int to System.Int32 or bool to System.Boolean.





Thank You.


No comments:

Post a Comment