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?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Use nullable types:
You can’t assign
nullto an element of the list because structs are value types, whilenullmeans an empty pointer, and so can only be assigned to reference type variables.Also note that
Listas you’re using it doesn’t exist in .NET! Perhaps you wantDictionary?