Is it possible to do something like the following in C#?
unsafe string GetName()
{
Foo[] foo = new Foo[2]; // Create an array of Foo and add two Foo elements
foo[0] = new Foo { Name = "Bob" };
foo[1] = new Foo { Name = "Jane" };
Foo *ptr = &foo; // Get address of the first element in the array
ptr++; // Move to the next element in the array
return *ptr.Name; // Expect Name to be "Jane"
}
I'm playing around with custom data structures, and I would like to be able to do this.
I know you can do it with int types etc, but what about user defined structs and classes?