Why are aliases for string and object lowercase?

Here is a list of aliases in C # (compliments What is the difference between a string and a 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 see that bool through char is lowercase aliases because they are primitive types.

Why are objects and strings not capitalized because they are complex types? Is this supervision by developers, or is there a necessary reason for them to be lowercase? Or is it a stubborn question?

You end up with things like string.Format() instead of string.Format() that just look scared and make me think that string is a variable.

+5
source share
4 answers

There are no "primitive types" or "complex types" in C #. There are class es and struct s (reference types and value types, respectively) and others. Both may include methods (e.g. char.IsDigit('a') ). So your objections are really invalid. But there is another question: why?

I'm not sure if there is a good source for this, but I think lowercase aliases are executed according to other C # keywords , which are themselves modeled by C / C ++ keywords.

+4
source

Because all keywords (reserved identifiers) are lowercase.

+11
source

Regarding your last comment:

You end up with string.Format() instead of string.Format() , which just looks funky and makes me think that the string is a variable.

With C # 6, this becomes a moot point, as you can:

 using static System.String; ... var x = Format(...); 

Or move on, you can completely abandon string.Format and use $ .

+2
source

The answer is simple. If you want to use it as a class, use String if you want to use it as the use String keyword. The developers wanted to make us feel like we were using a primitive type. Because in C # nothing is primitive.

-1
source

All Articles