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.
Because all keywords (reserved identifiers) are lowercase.
In C#, there are no "primitive types" and "complex types". There are class
es and struct
s, (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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With