0

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?

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by Momerath
0

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.

Edited by Momerath: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.