If someone could explain to me the difference between Decimal and decimal in C# that would be great.
In a more general fashion, what is the difference between the lo
As C# is a .NET language, all types must map to a .NET Framework Type.
To answer your first question, decimal is an Alias of the System.Decimal .NET Framework type. They may be used interchangeably.
To answer your second question, both Decimal and decimal should extend the same functions, including both from the created variable and from the "Structure" of the value type itself.
decimal FirstDec = 12;
Decimal SecondDec = 13;
decimal ThirdDec = decimal.Ceiling(FirstDec, SecondDec);
Decimal FourthDec = Decimal.Floor(ThirdDec);
bool isEqual = FirstDec.Equals(SecondDec) && FourthDec.Equals(ThirdDec);
The following MSDN Page for Built-In Types will show you which System.ValueType
each alias maps to. And for Decimal
and decimal
specifically, you can reference this MSDN Page for Decimal.
decimal, int, string are all just short hand notation to make things easier/prettier for you. The framework doesn't really know what a "decimal" is, but it does know System.Decimal, so when you compile your code, decimal just turns into System.Decimal. Try looking at some code where all the types are fully qualified, then try looking at some code where the aliases are used, I think most programmers will prefer the more compact aliases and perceive it as being easier to read. I also think it might be a throw back to C/C++ to make transitioning easier.
They are the same. The type decimal is an alias for System.Decimal.
So basically decimal is the same thing as Decimal. It's down to user's preference which one to use but most prefer to use int and string as they are easier to type and more familiar among C++ programmers.
The built-in C# types aren't all structs*. They are aliases for the predefined types in the System namespace. They are literally the same in all ways except formatting. The alias types are lowercase and formatted like keywords (dark blue). The System types are PascalCased and formatted like types (light blue).
*object
and string
are classes
Hadn't C# been case sensitive, some people would have written applications in all-caps as they did in Cobol and VB. This would have made it impossible for developers to read the code and maintain it. Case-sensitivity is a designer's effort to help making the language more usable.