So I am working on porting a very small chunk of code from VC++ to .NET. I have always been a VB guy, dabbled a bit in C# but not much, and have little to no knowledge in VC++. Yeah, I know, it's probably a bad idea to try and port code from a language you know nothing about, but I don't see the point in taking unnecessary time to learn the in's and out's of a language for the sake of porting a couple hundred lines of code. I have managed to learn enough to get a lot of it ported over, but somethings I am still unclear on. Here is the VC++ code:
#define ES16(_val) \
((u16)(((((u16)_val) & 0xff00) >> 8) | \
((((u16)_val) & 0x00ff) << 8)))
#define ES32(_val) \
((u32)(((((u32)_val) & 0xff000000) >> 24) | \
((((u32)_val) & 0x00ff0000) >> 8 ) | \
((((u32)_val) & 0x0000ff00) << 8 ) | \
((((u32)_val) & 0x000000ff) << 24)))
#define ES64(_val) \
((u64)(((((u64)_val) & 0xff00000000000000ull) >> 56) | \
((((u64)_val) & 0x00ff000000000000ull) >> 40) | \
((((u64)_val) & 0x0000ff0000000000ull) >> 24) | \
((((u64)_val) & 0x000000ff00000000ull) >> 8 ) | \
((((u64)_val) & 0x00000000ff000000ull) << 8 ) | \
((((u64)_val) & 0x0000000000ff0000ull) << 24) | \
((((u64)_val) & 0x000000000000ff00ull) << 40) | \
((((u64)_val) & 0x00000000000000ffull) << 56)))
Can someone explain what is going on here? And maybe provide a little insight as to how to re-write this in VB.NET (although, if I knew what was going on, I could surely re-write it myself, haha).
As always, thanks in advance everyone.