c# numeric types code example
Example 1: bytes size c#
public static string GetSizeInMemory(this long bytesize)
{
string[] sizes = { "B", "KB", "MB", "GB", "TB" };
double len = Convert.ToDouble(bytesize);
int order = 0;
while(len >= 1024D && order < sizes.Length - 1)
{
order++;
len /= 1024;
}
return string.Format(CultureInfo.CurrentCulture,"{0:0.##} {1}", len, sizes[order]);
}
Example 2: c# data types
sbyte myNum = 1;
uint myNum = 3;
short myNum = 4;
int myNum = 5;
long myNum = 10;
float myFloat = 1.2f;
double myDoubleNum = 5.99;
decimal myDecimalNum = 2.2M;
char myLetter = 'D';
string myString = "Hello!"
bool myBool = true;
Example 3: whats the main data types c#