在 C# 中,'where T : class' 是什么意思? [英] In c# what does 'where T : class' mean?

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

问题描述

在 C# 中 where T : class 是什么意思?

In C# what does where T : class mean?

即.

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).

请参阅这篇MSDN文章了解更多详情.

See this MSDN article for further details.

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

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