using System.Collections.Generic;
public static void Main()
string provaLotto = "Prova123456789_1011";
int maxLenght = provaLotto.Length > 23 ? 23 : provaLotto.Length;
string lotto = provaLotto.Substring(0, maxLenght);
Console.WriteLine(lotto);
List<byte> lottoArray = new List<byte>();
lottoArray.AddRange(System.Text.Encoding.Default.GetBytes(lotto).ToList());
for(int i = lottoArray.Count; i < 24; i++)
lottoArray.Add((byte) 0);
Console.WriteLine(lottoArray.Count);
Console.WriteLine(ByteArrayToBitString(lottoArray.ToArray()));
public static string ByteArrayToBitString(byte[] ba)
return string.Join( " ", ba.Select( x => Convert.ToString( x, 2 ).PadLeft( 8, '0' ) ) );