I have a trouble creating managed array of pointers.
I've tried
public unsafe class Car
{
public int speed;
public Car()
{
speed = 0;
}
public Car(int speed)
{
this.speed = speed;
}
}
class Program
{
public static unsafe void Main(string[] args)
{
var arr = new Car[10]; // 1st way
fixed(Car* ptr = arr)
{}
Car* arr = stackalloc Car[10]; // 2nd way
}
}
After both tries I get the same error: "Impossible to get adress or size or define a pointer of managed type". Does somebody know how to fix it?