0

When programming in C# does it matter if it's written as "String" or "string" when creating a variable ?

Here's an example , does it mater if string is written with a lower (s) or upper case (S) In visual studio ? Also when "String" is written like this it appears in green but when it's written like this "string" it's appears in blue. What's the difference between the lower and upper case versions and why do they appear in different colours ? String yourName = "Jim"; string myName = "Kim";

14th Aug 2017, 1:43 AM
Ronaldo
Ronaldo - avatar
2 Réponses
+ 3
string is an alias for System.String in the .NET framework, so there really is no difference between the two other than if you are using String you'll need to import the System namespace. They both compile to the same code.
14th Aug 2017, 2:06 AM
ChaoticDawg
ChaoticDawg - avatar
+ 2
Visual Studio, like other IDEs, have built in features to make code easy to read. One of these features are to highlight your code with different colors to make it easy for you to identify certain text in your code. This could be special keywords, strings, integers, functions, comments, etc. All with different colors so that it's easy for you to identify them. You can also change the colors in your settings to suit your preference. I'm not familiar with C++, so I don't know if declaring a data type is case sensitive but if it isn't then the lower case declaration is a different colour because it might take the form of another color identity. Example, it could be the colour of a "special keyword" instead of the colour of a "data type".
14th Aug 2017, 2:06 AM
Ghauth Christians
Ghauth Christians - avatar