By definition Nullable<> is a struct but when I call some generic function, it behaves like it's an object.
class GenController
{
public void Get<T>(T id) where T : struct
{
Console.Write("is struct");
}
public void Get(object obj)
{
Console.Write("is object");
}
}
long param1 = 1234;
new GenController().Get(param1);
// output is "is struct" as expected
long? param2 = 1234;
new GenController().Get(param2);
// output is "is object"
// obj seen at debug time as "object {long}"
// expected "is struct"
So the parameter is seen as an object instead of a struct.
Any idea of what's happening, am I misunderstanding the meaning of struct?
Is there a way to dispach Nullable<T> or T and object as different kind of parameters?