In C# we can declare a list to store int, like
List myList = new List {1,1,2};
I want to store null values as well (nullable type) hence I want to create a list of nullable types. Something like this
List<?int> myList = new List<int> {1,1,2};
Above code does not compile. Does .Net supports list of nullable types?
Atul Sureka
Sure, you need
List<int?> myList = new List<int?> {1,1,2};
int? not ?intAs a side note, you can't actually declare a list like List myList = new List {1, 1, 2}; as there's no non-generic List.
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