How does a computer represent a "5" in its memory?
EVERYTHING is stored as a binary code (1s and 0s).
But, there are MANY codes...
--------------------------
ASCII character: 0011 0101
UTF-8 unicode: 0011 0101 (same as ASCII in 8 bits)
Unsigned decimal(8 bits): 0000 0101
Signed decimal(8): 0000 0101 (same as unsigned for a positive #)
Unsigned decimal(16): 0000 0000 0000 0101
Unsigned decimal(32): 0000 0000 0000 0000 0000 0000 0000 0101
Floating Point (float): 0100 0000 1010 0000 0000 0000 0000 0000
Double (double): 0100 0000 0001 0100 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
This is why, whe reading in a number from the keyboard, a conversion must
take place. Sometimes the conversion is explicit and sometimes it is implicit.
int i;
double d;
string s;
// input the number - convert from string to 'number'
Console.Write( "Enter a number: " );
s = Console.ReadLine( );
i = int.Parse( s );
d = double.Parse( s );
// output the number - convert number back to string
Console.WriteLine( s );
Console.WriteLine( i.ToString( ) );
Console.WriteLine( d.ToString( ) );
or more simply...
i = int.Parse( Console.ReadLine() );
d = double.Parse( Console.ReadLine() );