JimDel
JimDel

Reputation: 4359

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

Upvotes: 7

Views: 2207

Answers (5)

iamrcw
iamrcw

Reputation: 31

I found that when I changed my Environment color scheme I lost some of the default code highlighting. By simply switching between other color themes(Blue,Dark,Light..) the code highlighting problem was resolved.

This can be done in TOOLS > Options > Environment

Upvotes: 1

Andy C
Andy C

Reputation: 795

If you're finding that your DateTime is black rather than colored I just got that when my VisualStudio config messed up and returned to default.

If you go TOOLS > Options > Environment > Fonts and Colors then scroll down to "User Types (Value Types)" then change it to a different color syntax highlight of DateTime is restored (it seems to sometimes bug out and not highlight even through it's set to a color)

Upvotes: 0

venkat balabhadra
venkat balabhadra

Reputation: 537

DateTime is a class and your instantiating an object of a class, where as other primitive data types such as int, float are all keywords.

Upvotes: 1

Cubicle.Jockey
Cubicle.Jockey

Reputation: 3328

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

Upvotes: 2

keyboardP
keyboardP

Reputation: 69372

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.

Upvotes: 14

Related Questions