c# – Binary to ASCII character in C #


A binary code is entered into the program (For example: 10101001010100), you need to translate it into ASCII characters (string)


Perhaps something like this will do


using System;
using System.Text.RegularExpressions;

public class Test
    public static void Main()
        var a = "10101001010100";
        Console.WriteLine(Regex.Replace(a, "[01]{7}", m => ((char)Convert.ToByte(m.Value, 2)).ToString()));

But if performance is important, it might be worth considering another method.

Scroll to Top