Hi!
I have this code:
public void Add<T>(T item)
{
if (item == null)
throw new ArgumentNullException();
...
}
but there is a problem - when you look at MSIL code:
... L_0001: box !0 ...
There is a boxing, because T can be value type, so it is boxed to be compared against null (I suppose
I tried this:
if (item == default(T))
throw...
...
but this does not compile.
Does anybody know how to avoid that boxing?
Thanks.
Thread Closed
This thread is kinda stale and has been closed but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.