KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
public void DoFoo<T>(T foo) where T : ISomeInterface<T> { //possible compare of value type with 'null'. if (foo == null) throw new ArgumentNullException("foo"); } I'm purposely only checking against null because I don't want to restrict a ValueType from being equal to its default(T) . My code compiles and works just fine this way (ReSharper complains, but not CodeAnalysis). Though I do wonder: Is there a more standard way to handle this situation? Is there any chance of an issue arrising from this? What truly happens under the hood when I make a call and pass in a value type?
Tags (comma-separated)
Save Edits
Cancel