c#范型体验1
发表于:2007-06-30来源:作者:点击数:
标签:
写了点代码,初次体验到C#范型的魅力
class Program
{
static void WriteSometing<T>(T x,T y)
{
if (typeof(T) == typeof(int))
Console.WriteLine(x);
if (typeof(T) == typeof(string))
Console.WriteLine(y);
}
static void Main(string[] args)
{
WriteSometing<int>(0, 9);
WriteSometing<string>("0", "9");
WriteSometing(0, 9);
WriteSometing("0", "9");
Console.ReadLine();
}
}
原文转自:http://www.ltesting.net