I've got a simple struct.

struct Data
    {
        public float Size;

        public Data(float size)
        {
            Size = size;
        }
    }

If I create an array of the struct above, the array does not initialise each element to null. How can I change this?

struct is considered a value type, and thus us non-nullable. You can make it a nullable type (by using the ? operator) but this has it's own issues as you'll have to redefine the inner portions of your struct.

Just change struct to class and all is good in the world.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.