Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- From Decimal to Binary:
- int n = int.Parse(Console.ReadLine());
- var convert = Convert.ToString(n, 2);
- Console.WriteLine(convert);
- From Binary to Decimal:
- string bin = Console.ReadLine();
- int result = Convert.ToInt32 (bin, 2 );
- Console.WriteLine(result);
- From Decimal To Hexadecimal:
- int n = int.Parse(Console.ReadLine());
- var convert = Convert.ToString(n, 16);
- Console.WriteLine(convert);
- 2nd Version with placeholder:
- int n = int.Parse(Console.ReadLine());
- Console.WriteLine("{0:X}" , n);
- From Hexadecimal to Decimal:
- string bin = Console.ReadLine();
- int result = Convert.ToInt32(bin, 16);
- Console.WriteLine(result);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement