So, I had a code like this (detail):
namespace itssafe
{
public unsafe partial class testing : Form
{
unsafe private static int original = 10;
unsafe private int tmp;
unsafe setter() // I'll use this several time
{
tmp = original;
}
unsafe private void Form1_Load(object sender, EventArgs e)
{
setter();
}
unsafe private void timers_Tick(object sender, EventArgs e)
{
int* counter; // working
counter = &tmp; // not working, but I need this
}
}
}
And I had a global variable, called "tmp" and I need to create a pointer what point to it. But I can't, because I get "CS0212 You can only take the address of an unfixed expression inside of a fixed statement initializer" error. But the variable is global so I can't create in this method, because I need to use elsewhere too. What can I do?
I know I'm using to many unnecessary "unsafe", but i'm so desperate.