C# 接口 泛型
接口使用泛型,并被类实现接口
using System; namespace ClassAndIn { internal class Program { static void Main(string[] args) { // int 类型 Studnet<int> studnet = new Studnet<int>(); studnet.Id = 10; studnet.Name = "Test"; Console.WriteLine($"id:{studnet.Id},name:{studnet.Name}"); // string 类型 Studnet<string> studnet1 = new Studnet<string>(); studnet1.Id = "0001"; studnet1.Name = "tony"; Console.WriteLine($"{studnet1.Id}---{studnet1.Name}"); } } interface IUnique<T> { T Id { get; set; } } class Studnet<T> : IUnique<T> { public T Id { get; set; } public string Name { get; set; } } }