开发者

Read byte array byte by byte using C#

I have a byte a开发者_运维百科rray and I want to read this array byte by byte and displayed each byte as integer.

how to do this using C#?


Given that the array is called bytes:

foreach(var b in bytes)
{
    Console.WriteLine((int)b);
}

Though, in all fairness, the cast to int is probably unnecessary for display purposes.


Some of the C# code I have been writing communicates via TCP/IP with legacy C++ applications. Some codes use a raw packet format where C/C++ structures are passed back and forward.

Example of what the legacy code could look like: Best Practice Mapping a byte array to a structure in C#

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜