In c# what does 'where T : class' mean?

前端 未结 10 1976
太阳男子
太阳男子 2020-11-29 18:53

In C# what does where T : class mean?

Ie.

public IList DoThis() where T : class
10条回答
  •  再見小時候
    2020-11-29 19:13

    It is called a type parameter constraint. Effectively it constraints what type T can be.

    The type argument must be a reference type; this applies also to any class, interface, delegate, or array type.

    Constraints on Type Parameters (C# Programming Guide)

提交回复
热议问题