I never needed to use unsafe in the past, but now I need it to work with a pointer manipulating a bitmap.
I couldn't find any documentation that indicates otherwise, but I would like to understand better how unsafe works and if it makes any difference to use it inside or outside a loop.
Is it better to do:
unsafe
{
for (int x = 0; x < maxX; x++)
{
for (int y = 0; y < maxY; y++)
{
//Unsafe pointer operations here.
}
}
}
Or to do?:
for (int x = 0; x < maxX; x++)
{
for (int y = 0; y < maxY; y++)
{
unsafe
{
//Unsafe pointer operations here.
}
}
}