Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

5
  • 2
    Or you can use default(T) Commented Feb 15, 2021 at 18:45
  • @Dennis_E that's actually a great one Commented Feb 15, 2021 at 18:48
  • @Dennis_E I would say you should post thus as an answer. Commented Feb 15, 2021 at 18:53
  • @Dmitry Bychenko (initial quesiton comments) correctly stated, that default(T) will not equate to null when dealing with structs like int, bool, etc Commented Feb 15, 2021 at 19:10
  • If the goal is to specifically add null to the list, default(T), in and of itself, does not guarantee so, therefore it wouldn't be a good answer to this post. Commented Feb 15, 2021 at 19:12