class Mock
{
public static explicit operator String(Mock s)
{
return "ok";
}
}
static T GetValue<T>(object o)
{
return (T)o;
}
Mock m = new Mock();
var v1 = (string) m;
var v2 = GetValue<string>(m); // InvalidCastException is thrown.
// How to modify GetValue method
// internally, without changing its
// signature, for this casting to work ?
問候如何從對象引用