泛型转化的问题

startray 2011-01-24 04:32:16
inface

public interface aa
{
int test(Entity);
}

class:

public clasee bb:aa
{
public int test(Entity en)
{...操作;return 1;}
}

public classfactory
{
static getclass(){}
}

public testclass1()
{
aa abc = (aa)classfactory.getclass();
aa abc = classfactory.getclass()<aa>;?不用以前的那种转换法。怎么做呢
//这儿要修改为泛型表示,怎么修改呀?那个类里的方法需要修改?
}
...全文
139 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
wuyq11 2011-01-24
  • 打赏
  • 举报
回复
public interface IBaseDAL<T> where T : BaseModel, new()
{
int Add(T model);
int Update(T model);
int Delete(T model);
}

IBaseDAL<News> newsDAL = factory.GetDAL<News>();
bloodish 2011-01-24
  • 打赏
  • 举报
回复

public class classfactory
{
static T getclass<T>() where T : aa
{
//todo
//return default(T);
}
}

110,532

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧