Articles that updated a long time ago may have already lost the technical merit. Please kindly pay attention while reading.

进制转换:

bin = Convert.ToString(dec, 2);

缺位补零:

bin = bin.PadLeft(8, '0');