这是什么C#语法是什么意思? [英] What does this C# syntax mean?

查看:165
本文介绍了这是什么C#语法是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我期待在源$ C ​​$ C为MvcContrib电网,看到声明为类:

I'm looking at the source code for the MvcContrib Grid and see the class declared as:

public class Grid<T> : IGrid<T> where T : class

什么的其中T:类位做

推荐答案

这是一个泛型类型约束

在这种情况下,这意味着泛型类型( T )必须是引用类型,即类,接口,委托或数组类型。

In this case it means that the generic type (T) must be a reference type, that is class, interface, delegate, or array type.

其他方面的限制此处上市

Other constraints are listed here.

您也可以约束泛型类型从一个特定的类型(基类或接口)

You can also constrain the generic type to inherit from a specific type (base class or interface)

这篇关于这是什么C#语法是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆