public static void Bar<T>(dynamic obj)
bool IsTypeRight = (typeof(Obj1) == typeof(T) || typeof(Obj2) == typeof(T));
bool IsObjRight = obj is T;
if (!IsTypeRight || !IsObjRight)
string.Format("Expecting type of <{0}>.", typeof(T).Name);
throw new System.ArgumentException(message);
public static void Foo<T>(dynamic obj)
string.Format("Expecting type of <{0}>.", typeof(T).Name);
throw new System.ArgumentException(message);
public static void Main()
System.Console.WriteLine("${0} at ${1}/hr.", obj.Cost, obj.Rate);
public string Cost, Rate;
public string Cost, Rate;