I'm new to C#.
Firstly, may I ask if int is the default type for integers in C#? In other words, are literals of whole number being treated as int in C#?
If so, since we can always declare, say, a byte as follows:
byte b = 1;
may I ask if there is an implicit type conversion happening during this initialisation (my guess: literal 1 is being treated as int first and then being converted to byte)?
If my guess above is correct, may I ask why we are allowed to implicitly convert int to byte using literal as above while we cannot do that when the literal is replaced by a variable of type int (say for example as follows)?
int a = 1;
byte c = a; // error
Moreover, I found that for constants:
const int d = 1;
byte f = d; // no error
const long g = 1;
int i = g; // error
byte h = g; //error
Could anyone please give more explanations on these?
I'm asking this since it gives me a feeling of inconsistency.
Many thanks