Type Conversion
:
Implicit: byte b = 1; //takes 1 byte of memory
int i = b; //integer takes 4 bytes
(you can copy a byte into an int, but not
an int into a byte). // won't CompileExplicit: float f = 1.0f;
int i = (int)f;(casting)Conversion between non-compatible types:
string s = "1";
int i = Convert.ToInt32(s)
int j = int.Parse(s);
Convert Methods():Examples
ToByte() //To convert to a byte
ToInt16() //To convert to a 16 "Short"
ToInt32() //To convert to a 32 "int"
ToInt64() //To convert to a 65 "Long"
Top comments (0)