I have a list:
List<int, SomeStruct>
For some reason, it is not allowing me to assign null values to it. What do I do if I want to have no struct associated?
Use nullable types:
List<int, SomeStruct?>
You can't assign null
to an element of the list because structs are value types, while null
means an empty pointer, and so can only be assigned to reference type variables.
Also note that List
as you're using it doesn't exist in .NET! Perhaps you want Dictionary
?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With