Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why doesn't Visual Studio make DateTime a Blue Key word?

If I understand it correctly, Visual Studio is supposed to Color Data Types Blue. So why doesn't it do that with DateTime?

enter image description here

Thanks

like image 892
JimDel Avatar asked Aug 03 '13 18:08

JimDel


2 Answers

int is a keyword as defined in the C# Language specs, whereas DateTime is a struct. If you use Int32, you'll notice that that too will turn to the same colour as DateTime because Int32 is not a keyword (even though int is an alias for Int32).

The default colour settings in Visual Studio is to highlight keywords blue which is why the keywords you've shown are in blue.

like image 69
keyboardP Avatar answered Sep 24 '22 03:09

keyboardP


DateTime is not a keyword; it is a struct, which is a ValueType, whereas a class is a Reference type. These are not considered primitives, so they are not colored unless you change the color in your VS settings.

Technically the keywords int, string, bool, and double are keywords, but they map to their Struct equivalent in the .NET framework. This way an int works the same in VB and C#.

So an int maps to Int32 Struct. They are colored blue to mimic primitive types as they are in other languages.

Details

like image 37
Cubicle.Jockey Avatar answered Sep 22 '22 03:09

Cubicle.Jockey