Timeline for How do I add null to a List of generic type? [duplicate]
Current License: CC BY-SA 4.0
7 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Feb 23, 2021 at 5:57 | vote | accept | AbandonedCrypt | ||
| Feb 15, 2021 at 19:00 | comment | added | Dmitrii Bychenko | list = Enumerable.Repeat(default(T), size).ToList(); note, that if T is struct (e.g. int, bool etc.), default(T) will not be null | |
| Feb 15, 2021 at 18:57 | history | closed | Servy c# Users with the c# badge or a synonym can single-handedly close c# questions as duplicates and reopen them as needed. | Duplicate of How can I return NULL from a generic method in C#? | |
| Feb 15, 2021 at 18:46 | comment | added | AbandonedCrypt | @David I spent a while trying to figure this out, T is a reference type and once I added where T : class to the constraints I was able to add the null member. Avoidable question, but maybe someone else runs into this problem and can benefit from this. | |
| Feb 15, 2021 at 18:44 | comment | added | David | What is T in this context? | |
| Feb 15, 2021 at 18:44 | answer | added | AbandonedCrypt | timeline score: 0 | |
| Feb 15, 2021 at 18:42 | history | asked | AbandonedCrypt | CC BY-SA 4.0 |