using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; namespace 泛型比较大小
{
class Program
{
//Compare<T>是泛型类,T为类型参数
public class Compare<T> where T : IComparable
{
//使用泛型实现的比较方法
public static T compareGeneric(T t1, T t2)
{
if (t1.CompareTo(t2) > )
{
return t1;
}
else
{
return t2;
}
}
}
static void Main(string[] args)
{
//调用泛型方法
Console.WriteLine(Compare<int>.compareGeneric(, ));
Console.WriteLine(Compare<string>.compareGeneric("aa", "a"));
Console.ReadKey();
}
}
}

最新文章

  1. C# 对多个文件进行zip压缩
  2. 用Java实现网络爬虫
  3. Clr静态数据Table-Valued函数
  4. Shell 语法 if 、 case 、for 、 while、 until 、select 、repeat、子函数
  5. 使用VS把ASP.NET 5的应用发布到Linux的Docker上
  6. extjs ajax请求与struts2进行交互
  7. C# WinForm获取当前路径汇总
  8. class dict
  9. MAC OS JAVA环境变量配置
  10. js中动态载入css js样式
  11. eclipse创建项目时出现appcompat_v7包及解决办法
  12. Python的模块,模块的使用、安装,别名,作用域等概念
  13. INKDIE
  14. 【好程序员笔记分享】——UIView与CALayer详解
  15. RadioButton 和 RadioButtonList 比较
  16. PHP获得文件创建、修改、访问时间 filectime() filemtime() fileatime()
  17. Linux中MySQL5.6编译安装与MySQL5.7二进制安装步骤
  18. NOIP2017划水记
  19. NodeJS定时任务
  20. Mahout系列之----kmeans 聚类

热门文章

  1. Introducing RecyclerView(二)
  2. Web Service学习笔记(webservice、soap、wsdl、jws详细分析)
  3. 【HDOJ】1114 Piggy-Bank
  4. hadoop2.2原理:分析HDFS的文件读写
  5. SQL语句优化方法
  6. ArchLinux安装开源VMware Tools
  7. c#自定义液晶数字控件
  8. [Irving] Android 点击两次返回退出系统
  9. SQL Server 2008如何进行数据库同步?
  10. ab的排列 aa , ab ba,bb