C# allows you to use pointers via the unsafe
construct. This also allows you to perform pointer arithmetic. While this may be useful to you, particularly if you're performing low-level operations, it is also possible that you may end up trying to access incorrect memory locations or regions that you aren't supposed to access. It is therefore recommended that you validate all the parameters and offsets that you're using when performing pointer arithmetic.
var newPtr = oldPtr + offset;
*newPtr = value;
if (offset > lb && offset < ub)
{
var newPtr = oldPtr + offset;
*newPtr = value;
}