/*
Author: Jiangong SUN
*/
For the purpose of introducing the value types of CSharp language, and making it more clearly to developers, I'm writing this post. I'll list some samples and try to figure out some common misunderstandings about the concepts. And I will update the articles from time to time when I think it's necessary and I have some new understanding about them.
I have made some conclusion about the value types in my another post which could be helpful.
Here we go !
1) Boolean type:
Boolean type has only two possible values: true, false.
Someone may think Boolean and bool are different when you create a new boolean variable.
Next, I'll compare the code generated, you will find the code are identical.
In fact, "bool" is an alias for "System.Boolean". Just like "int" for "System.Int32" and "string" for "System.String".
You can see all the alias here
2) Integral Types
There is a predefined implicit conversion from sbyte to short, int, long, float, double, or decimal.
To declare a decimal value, you need to use "m" as suffix. like:
decimal xD = 100.13m;