Dysfunctional Example:
public struct MyStruct { public int i, j; }
static readonly MyStruct [] myTable = new MyStruct [3]
{
{0, 0}, {1, 1}, {2, 2}
}
I know that this code doesn't work. Now how do I write this down please (proper syntax)?
The thought behind this is the following. Afaik the elements of arrays of struct are value types, so myTable points to a memory location containing three MyStruct objects (and not to a memory location containing three (uninitialized) pointers to MyStruct objects).
So how do I go about initializing those MyStruct objects, what would be the right syntax? I don't have to allocate them anymore, right?