How to code this C++ function in C#?

bal*_*nta -6 c# c++

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#?

R. *_*des 8

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.