C # - Reading bytes, what it is and what happens. I expect binary values, not decimal numbers

I have been a programmer for several years, but I never had to understand low-level operations with bytes. This interests me, and I would like to know more about working with bytes.

In the code below, I am reading a text file containing only the words "hello there."

        FileStream fileStream = new FileStream(@"C:\myfile.txt", FileMode.Open);

        byte[] mybyte = new byte[fileStream.Length];

        fileStream.Read(mybyte, 0, (int)fileStream.Length);

        foreach(byte b in mybyte)
            Console.Write(b);

        Console.ReadLine();

In this case, the mybyte variable contains numeric values ​​that appear to represent the decimal ASCII character. However, my bytes represent bits, which in turn represent binary values. When reading a byte, I would expect to see a binary value like "0001010", not "104", which is the ascii character for "h".

, persepctive . , , , Ascii, , , , ascii, - ( , ).

, , , , .

- .net- ( ). .

, " ", myfile.txt Byte array of the myfile.txt file.  Values ​​map to "hi there" , enter image description here

+3
4

01101000 - 8- 104. # 8 (0-255), . "", "Bin". .

, # , 0 255

+3

- 8- , 0 255 - , . , , . , , Visual Studio , , - .

, , .

, .

0

8 . -, , (104), (1101000) (68). , .

ASCII-. (7 , ).

0

, . , , - . , , , ( ).

, filestream , :

FileStream fs = new FileStream(@"<Filename>", FileMode.Open, FileAccess.Read, FileShare.Read);
            byte[] bt = new byte[8];
            fs.Read(bt , 0, 1);
            string str = System.Text.ASCIIEncoding.ASCII.GetString(bt);

ASCII, . Image,

Bitmap bmp = (Bitmap)Image.FromFile(@"<Filename>");

BMP , .

: 0 1 . .

0

All Articles