例子1:class
//where跟着泛型約束,該類型實現比較器,能夠進行比較泛型
public class FXClass<T> where T : IComparable
{static
public static T returnTag(T o1, T o2)
{return
if (o1.CompareTo(o2) > 0)
{
return o1;
}
return o2;
}
}ab
例子2:
public T Fx<T>(T o1, T o2) where T:IComparable
{
if (o1.CompareTo(o2) > 0)
{
return o1;
}
return o2; }