Simple types / Numbers / Integer

using System;

//decimal number system
int nDecimal = 42;

//octal number system
int octal = Convert.ToInt32("42"8);
//octal is 34

//hexadecimal number system
int hexadecimal = 0x42;
//hexadecimal is 66

//binary number system
int binary = Convert.ToInt32("1010"2);
//binary is 10

//42 to decimal string
string sDecimal = 42.ToString();
//sDecimal is "42"

//42 to octal string
string sOctal = Convert.ToString(428);
//sOctal is "52"

//42 to hexadecimal string
string sHexadecimal = Convert.ToString(4216);
//sHexadecimal is "2a"

//42 to binary string
string sBinary = Convert.ToString(422);
//sBinary is "101010"

Console.WriteLine($"nDecimal = {nDecimal}");
Console.WriteLine($"octal = {octal}");
Console.WriteLine($"hexadecimal = {hexadecimal}");
Console.WriteLine($"binary = {binary}");
Console.WriteLine($"sDecimal = {sDecimal}");
Console.WriteLine($"sOctal = {sOctal}");
Console.WriteLine($"sHexadecimal = {sHexadecimal}");
Console.WriteLine($"sBinary = {sBinary}");