泛型接口的类型参数要么已实例化,要么来源于实现类声明的类型参数
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace GenericInterFace
{
interface ICard<T>
{
T PrintCardNo(T t);
}
class Card
{
public string CardNo = "123456";
}
class CardManager : ICard<Card>
{
public Card PrintCardNo(Card t)
{
Console.WriteLine("My card number is {0}!", t.CardNo);
return t;
}
//泛型方法的T类型作用于参数和方法体内
public void SwapCard<T>(ref T card1, ref T card2)
{
T temp = default(T);
temp = card1;
card1 = card2;
card2 = temp;
}
}
class Program
{
static void Main(string[] args)