C#语法手册

泛型接口的声明


泛型接口的基本语法。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CSGDemoCSG010
{
    //https://docs.microsoft.com/zh-cn/dotnet/standard/generics/interfaces

    //#csg010-01
    //泛型接口的声明
    //泛型接口中的泛型类型约束语法与泛型类是一致的
    public interface InterfaceGeneric<T> where T: new()
    {
        //#csg010-02
        //泛型方法语法
        void Add(T t);

        //#csg010-03
        //泛型属性语法
        static T TypeValue { get; set; }

        //#csg010-04
        //泛型索引器语法
        T this[int i]
        {
            get;
            set;
        }

    }


}