這可能是瘸腿的,但在這裏:C#初始化問題
public interface Interface<T>
{
T Value { get; }
}
public class InterfaceProxy<T> : Interface<T>
{
public T Value { get; set; }
}
public class ImplementedInterface: InterfaceProxy<Double> {}
現在我想創建ImplementedInterface
的實例,並初始化它的成員。
可以這樣做這樣做(使用初始化列表)或只能使用構造函數與Double
參數實現相同的行爲?
var x = new ImplementedInteface { 30.0 };
絕對不是跛腳,很好的問題。 +1 – Gabe 2010-12-07 16:27:26