在C#中,怎么给泛型类的属性赋值?如下报错:Error 1 A new expression requires (), [], or {} after type
classClassA<T,S>{publicTt;publicSs;publicTtFun{get{returnt;}set{t=value;}}}在UI中调用的如下:...
class ClassA<T,S>
{
public T t;
public S s;
public T tFun
{
get {return t;}
set { t=value ;}
}
}
在UI中调用的如下:
protected void Page_Load(object sender, EventArgs e)
{
ClassA<int,int> A =new ClassA <int ,int >
A.tFun =5;
A.s =5;
A.t = 6;
lblShowClassA .Text =( A.s+ A.t ).ToString ();
} 展开
{
public T t;
public S s;
public T tFun
{
get {return t;}
set { t=value ;}
}
}
在UI中调用的如下:
protected void Page_Load(object sender, EventArgs e)
{
ClassA<int,int> A =new ClassA <int ,int >
A.tFun =5;
A.s =5;
A.t = 6;
lblShowClassA .Text =( A.s+ A.t ).ToString ();
} 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询