It is doable in C/C++. If you have a register (say in a micro controller) and you wish to read the value (since it can change outside of your code, hardware-wise), then you can
#define PORTBASE 0x40000000
unsigned int volatile * port = (unsigned int *) REG;
*port = value; /* write to port */
value = *port; /* read from port */
I am not sure it can be done in C#.
Hope that was relevant.
1
solved C# or C++ ; It is possible to modify memory like in CE? [closed]