C#C
C#11mo ago
PowerZox

Parameterless constructor in struct

public struct MyStruct
{
    public int id;
    static int count = 0;

    public MyStruct() //Not allowed?
    {
        id = count++;
    }
}


Then public MyStruct[] myStruct = new MyStruct[100]; should call the MyStruct() constructor 100 times.

How can I do this?
Was this page helpful?