I have the following function in C++:
void put8At ( unsigned char *b, int pos, int v )
{
union
{
short a;
unsigned char b[2];
} u;
u.a = v;
b += pos;
*b = v & 0xff;
}
Run Code Online (Sandbox Code Playgroud)
How would you code this in C#?
Here's how I would code it in C++:
void put8At ( unsigned char *b, int pos, int v )
{
b[pos] = v & 0xff;
}
Run Code Online (Sandbox Code Playgroud)
This is probably easier to translate to C# now.
| 归档时间: |
|
| 查看次数: |
111 次 |
| 最近记录: |