I looked around and could not find an answer. Let's say I have this code:
class Command<T> : ICommand<T> { public void Execute(T parameter) { var isNull = parameter == null;
T can be any class, even a Nullable<> . Does the check above perform a box reason if T is a value type? I understand that this is the same as calling ReferenceEquals , which takes two object arguments from which a box can arise if T was a value type, if I understood correctly.
If the above action causes boxing, is there a preferable way to do this without causing a window to appear? I know that there is default(T) , but in the case of int , that is 0 , and I look to see if this value is null without its box. Also, I am looking to do this in a way that satisfies both the values ββand the reference types.
Mike-eee
source share