A while back (freshman year of high school) I asked a really good C++ programmer who was a junior to make a simple application to convert a string to binary. He gave me the
It's not clear precisely what you want, but here's what I think you want:
return Convert.ToString(int.Parse(str), 2); // "5" --> "101"
This isn't what the C++ code does. For that, I suggest:
string[] binaryDigits = str.Select(c => Convert.ToString(c, 2));
foreach(string s in binaryDigits) Console.WriteLine(s);