如何在C#中使用泛型来了解类的属性 [英] How to know properties of classes using generic in C#

查看:567
本文介绍了如何在C#中使用泛型来了解类的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用C#中的泛型来了解类的属性

How to know properties of classes using generic in C#

推荐答案

其中 [ ^ ] 关键字 [通用类型约束 [ ^ ].
泛型类型约束是强制引用类型或值类型仅在满足类型约束中指定的确切要求的情况下,才可以在泛型类型的变量定义中使用引用类型或值类型的巧妙方法. br/>
如果您在阅读类型参数的约束(C#编程指南)上找到的文档后仍有疑问[ ^ ]随时回来给我留言.

问候,

曼弗雷德(Manfred)
In the definition of a generic type[^] you can use the where[^] keyword[^] to add a generic type constraint[^].
Generic type constraints are a neat way to enforce that a reference type or value type can only be used in the definition of a variable in conjunction with the generic type if it satisfies the exact requisites that were specified in the type constraint(s).

If you still have doubts after reading the documentation found on Constraints on Type Parameters (C# Programming Guide)[^] feel free to come back and leave me a comment.

Regards,

Manfred


这篇关于如何在C#中使用泛型来了解类的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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