Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are the aliases for string and object in lowercase?

Here are a list of aliases in C# (compliments of What is the difference between String and string in C#?):

object:  System.Object
string:  System.String
bool:    System.Boolean
byte:    System.Byte
sbyte:   System.SByte
short:   System.Int16
ushort:  System.UInt16
int:     System.Int32
uint:    System.UInt32
long:    System.Int64
ulong:   System.UInt64
float:   System.Single
double:  System.Double
decimal: System.Decimal
char:    System.Char

I can see bool through char being lowercase aliases, because they are primitive types.

Why are object and string not capitalized, since they are complex types? Is this an oversight by the developers, or is there a necessary reason for them to be lowercase? Or is this an opinionated question?

You end up with things like string.Format() instead of String.Format(), which just look funky and make me think string is a variable.

like image 983
Evorlor Avatar asked Jun 08 '15 15:06

Evorlor


2 Answers

Because all keywords (reserved identifiers) are lowercase.

like image 89
Sehnsucht Avatar answered Sep 17 '22 02:09

Sehnsucht


In C#, there are no "primitive types" and "complex types". There are classes and structs, (reference types and value types, respectively) among others. Both can include methods (e.g. char.IsDigit('a')). So your objections aren't really valid. But there is still the question: why?

I'm not sure if there's a good source for this, but I think the lowercase aliases are done to match the other C# keywords, which are themselves modeled on C/C++ keywords.

like image 29
Tim S. Avatar answered Sep 17 '22 02:09

Tim S.