Answers for "convert character to binary using c#"

C#
2

c# to binary

int value = 8;
string binary = Convert.ToString(value, 2);
// binary to base 10
int value = Convert.ToInt32("1101", 2)
Posted by: Guest on May-30-2020
1

byte to binary c#

string s = string.Join( " ",
        MESSAGE.Select( x => Convert.ToString( x, 2 ).PadLeft( 8, '0' ) ) );
Posted by: Guest on August-16-2020
-1

c# string to binary

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')));
}

// Use any sort of encoding you like. 
var binaryString = ToBinary(ConvertToByteArray("Welcome, World!", Encoding.ASCII));
Posted by: Guest on September-19-2021

Code answers related to "convert character to binary using c#"

C# Answers by Framework

Browse Popular Code Answers by Language