There is the following code:
long hex; const string Text = "D0 9F D0 BE D1 81 D1 82 D0 BE D0 B9 "+ "2C 20 D0 BF D0 B0 D1 80 D0 BE D0 B2 D0 BE D0 B7 2C 20 D0 "+ "BD D0 B5 20 D1 81 D1 82 D1 83 D1 87 D0 B8 D1 82 D0 B5 20 "+ "D0 BA D0 BE D0 BB D0 B5 D1 81 D0 B0 2E"; string[] words = Text.Split(' '); foreach (string word in words) { hex = Convert.ToInt32(word, 16); Console.WriteLine("{0:x} : шестнадцатеричная : " + String.Format("{0:00000000}",Convert.ToString(hex, 2)), hex); } Console.ReadLine(); According to the logic in the console, I want to output the value of the converted values, but contrary to the specified String.Format value, when outputting to the console, the zeros from the left are truncated. How to set the format correctly so that 8 bits are output to the console?
:000000does not apply to the string type. Alternatively, you can reparate it in long, then for long the formatter will add zeros, but for string it will definitely not. You have even answered almost the same. - nick_n_a