现在的位置: 首页 > 综合 > 正文

在范型中接口和实例间转换的问题Why No? .net 2.0 Generic cast Type From Instance to Interface

2013年11月12日 ⁄ 综合 ⁄ 共 398字 ⁄ 字号 评论关闭

Since OO age ,we were used to cast a interface from Instance class,  like this:

Iuser iu=new User();

that's  natural and easy , i like it;

however in .NET2.0 , have a new&hot feature call "generic" ,can write code less than beforetime,

but,when i try to write some code mixing interface/instance & generic , i got a big problem

this :

           List  ius = new List();

or this:

           List  us = new List();

anyway impossible!

anyone would like to give me some suggestions?

抱歉!评论已关闭.