且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在C#是什么',其中T:类'是什么意思?

更新时间:2023-11-08 13:41:16

简单把这个是制约泛型参数的一类(或更具体地说这可能是一个类,接口,委托或数组类型的引用类型)。



请参阅此 MSDN文章进一步的细节。


In C# what does where T : class mean?

Ie.

public IList<T> DoThis<T>() where T : class

Simply put this is constraining the generic parameter to a class (or more specifically a reference type which could be a class, interface, delegate, or array type).

See this MSDN article for further details.