Consider two extension methods:
public static T MyExtension(this T o) where T:class
public static T MyExtension(this T o) where T:struct
>
Eric Lippert explains better than I ever could, here.
I have come across this myself. My solution was
public void DoSomthing (T theThing){
if (typeof (T).IsValueType)
DoSomthingWithStruct (theThing);
else
DoSomthingWithClass (theThing);
}
// edit - seems I just lived with boxing
public void DoSomthingWithStruct (object theThing)
public void DoSomthingWithClass(object theThing)