using System using System Collections Generic using System Linq public

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
using System;
using System.Collections.Generic;
using System.Linq;
public class Program
{
public static void Main()
{
Console.WriteLine("Choose number system(b - binary, d - decimal)");
String numSystem = Console.ReadLine();
if (numSystem != "b" && numSystem != "d") {
Console.WriteLine("Please, try again");
return;
}
Console.WriteLine("Enter a number");
String num = Console.ReadLine();
if (numSystem == "b") {
Console.WriteLine("Binary: " + num);
Console.WriteLine("Decimal: " + Convert.ToInt32(num, 2));
} else {
Console.WriteLine("Decimal: " + num);
Console.WriteLine("Binary: " + Convert.ToString(Int32.Parse(num), 2));
}
}
}