Hi all,
Was reading a book today about data types in C# and have a few burning and itchy questions. They're fundamental concepts, but it's more to the details(Computer Science level).
1) Consider the following : Code:
int n, a, b;
and Code:
int n;
int a;
int b;
It's said that the 1st style above will cost some performance loss. Is it true?(even though I know it won't be noticeable)
2) Is it that a long can store the same amount of digits as a double(both are 8 bytes large), only that a double can store decimal digits as well?
3) In C#, a float is 4 bytes, a double is 8 bytes and a decimal is 16 bytes. The decimal data type stores less digits than a float or a double, but how can it take up 16 bytes???!!!
4) A bool requires 1 byte of memory(8 bits). Since we all know that the bool data type can store only a TRUE(1) or a FALSE(0), shouldn't it take up just 1 bit instead of 1 byte? After all, the value 1(TRUE) or 0(FALSE) can be stored in 1 bit, and doesn't require 8 bits(1 byte).
5) Code:
System.Int32 m_myvar = 500;
and Code:
int m_myvar = 500;
When this program is run under the .Net(CLR) enviroment, will the 1st style execute slightly faster(even if un-noticeable) than the 2nd style, because we're using the .Net data type directly?(something like calling the Win32 API directly instead of wrappers like MFC)
6) Code:
float my_var = 1.35F;
I saw the above code in the book today. Is there a real need to add the 'F' behind to tell the compiler that this is a float? I mean, any advantages or practicality reasons behind this?
Thanks!
Xeon.