Can someone explain why the head and tail is reset to null once second IsAMatch is call even though id pass new pointers to it, the old ones get reset.
I have equivalent script on c++ and it works perfectly.
Any ideas ?
my code
small code example here it prints 10,20 so the second call changes first struct
class Program
{
static unsafe void Main(string[] args)
{
MyStruct* myStruct = null;
ChangeMe(ref myStruct, 10);
Console.WriteLine(myStruct->num);
MyStruct* myStruct2 = null;
ChangeMe(ref myStruct2,20);
Console.WriteLine(myStruct->num);
Console.ReadKey();
}
public static unsafe void ChangeMe(ref MyStruct* h, int v)
{
MyStruct myStructNew = new MyStruct(v);
h = &myStructNew;
}
public unsafe struct MyStruct
{
public int num;
public MyStruct(int n)
{
num = n;
}
}
}