static List<int> ConvertTextToBinary(int number, int Base)
{
List<int> list = new List<int>();
while (number!=0)
{
list.Add(number % Base);
number = number / Base;
}
list.Reverse();
return list;
}
static void Main(string[] args)
{
string s = "stackoverflow";
int counter=0;
while (counter!=s.Length)
{
int[] a = ConvertTextToBinary(s[counter], 2).ToArray();
for (int i = 0; i < a.Length; i++)
{
Console.Write(a[i]);
}
Console.Write("
");
counter++;
}
}
I wrote a method to convert string to binary, its working fine. But now I want to convert binary to string eg: 1101000 is equal to h.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…