I need help from String to Binary in C#.
I have tried to make it like '01100100',
but it comes out like 01100100',
without the apostrophe on the left side. In my code it says pad left(8, '0') and I can't seem to get it like (1, " ' ") or something.
private void Button2_Click_1(object sender, EventArgs e)
{
richTextbox1.Text = ToBinary(ConvertToByteArray(richTextbox1.Text, Encoding.ASCII));
}
public static byte[] ConvertToByteArray(string str, Encoding encoding)
{
return encoding.GetBytes(str);
}
public static String ToBinary(Byte[] data)
{
return string.Join("', ", data.Select(byt => Convert.ToString(byt, 2).PadLeft(8,'0')));
}