【发布时间】:2009-06-22 05:30:22
【问题描述】:
只是想知道在 C# 3.5 中是否有任何方法可以表示以下代码:
public struct Foo<T> {
public Foo(T item) {
this.Item = item;
}
public T Item { get; set; }
public static explicit operator Foo<U> ( Foo<T> a )
where U : T {
return new Foo<U>((U)a.Item)
}
}
谢谢
【问题讨论】:
标签: c# generics casting operator-overloading