C# 2.0 泛型下如何让 new T()调用构造函数时带参?
在.NET 2.0 C# 代码如下:
public class note {
private string _value;
public note(string entervalue) {
_value = entervalue;
}
public string getvalue {
get { return _value; }
}
}
public class notes<T> {
string[] items = new string[2];
items[0] = "1";
items[1] = "2";
public T this[int index] {
get {
return new T(index); // <-- 这一步该如何编写?
}
}
}
在public class notes<T> 加入 where T : new() 这个能够调用默认的构造函数
但是无法加入参数的! public class notes<T> where T : new() {...}
求高人解答。