static void Main(string[] args)
{
#region 具体类型可传递。
Personal specifiedPersonal = new Personal(); Employee<Personal> employee = new Employee<Personal>();
employee.Create(specifiedPersonal);
#endregion #region 动态类型传递到TModel。
//假设传递一个a进来
Personal a = new Personal();
var type = typeof(Employee<>).MakeGenericType(a.GetType());
dynamic a_Context = Activator.CreateInstance(type);
var q = a_Context.Create(a);
Console.WriteLine(q); #endregion Console.ReadLine();
} public class Personal
{
public string FirstName { get; internal set; }
public string LastName { get; internal set; }
}
public interface IEmployee<TModel>
{
Guid Create(TModel model);
bool Update(TModel model);
} public class Employee<TModel> : IEmployee<TModel>
{
public Guid Create(TModel model)
{
// TODO :
return Guid.NewGuid();
}
public bool Update(TModel model)
{
// TODO :
return true;
}
}
---------------------
作者:正怒月神
来源:CSDN
原文:https://blog.csdn.net/hanjun0612/article/details/84954340
版权声明:本文为博主原创文章,转载请附上博文链接!

最新文章

  1. 学习之路~sqh
  2. 【CityHunter】通过Unity3D来制作游戏中AR部分的内容
  3. java生产者/消费者模式实现——一生产者一消费者(操作值)
  4. Stanford NLP 学习笔记2:文本处理基础(text processing)
  5. jquery ajax json简单的分页,模拟数据,没有封装,只显示原理
  6. cxx-generator JS绑定工具
  7. BZOJ 4031: [HEOI2015]小Z的房间 Matrix-Tree定理
  8. mysql存储过程及经常使用函数
  9. Android 调试工具集【转】
  10. hdu_1429_胜利大逃亡(续)(BFS状压)
  11. 【知了堂学习笔记】_String、StringBuffer与StringBuilder的区别
  12. Leetcode: Max Consecutive Ones II(unsolved locked problem)
  13. 分布式系统消息中间件——RabbitMQ的使用基础篇
  14. Linq中比较字符串类型的日期
  15. HDU 1017(** **)
  16. 转 Multiple outputs from T4 made easy t4生成多文件
  17. InfluxDB 的UTC时间问题与简单的持续查询语句
  18. CentOS中用Nexus搭建maven私服,为Hadoop编译提供本地镜像
  19. 学会使用Fidder抓取app的http请求(转)
  20. VS提示无法连接到已配置的开发web服务器的解决方法

热门文章

  1. React-菜鸟学习笔记(二)
  2. redis-trib.rb命令详解
  3. Rollup处理并打包JS文件项目实例
  4. 《Spring Boot 入门及前后端分离项目实践》系列介绍
  5. Jenkins- job之间传参
  6. Python-可变参数和关键字参数(*args **kw)
  7. 多路选择器实现总线结构——Verilog
  8. Mike and strings CodeForces - 798B (又水又坑)
  9. Linux下破解pycharm
  10. nmon for Linux &amp; Java