博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
C# - Generics
阅读量:4678 次
发布时间:2019-06-09

本文共 1235 字,大约阅读时间需要 4 分钟。

Generics were added to version 2.0 of the C# language and the common language runtime (CLR). Generics introduce to the .NET Framework the concept of type parameters, which make it possible to design classes and methods that defer the specification of one or more types until the class or method is declared and instantiated by client code. For example, by using a generic type parameter T you can write a single class that other client code can use without incurring the cost or risk of runtime casts or boxing operations.
  • Use generic types to maximize code reuse, type safety, and performance.
  • The most common use of generics is to create collection classes.
  • The .NET Framework class library contains several new generic collection classes in the System.Collections.Generic namespace. These should be used whenever possible instead of classes such as ArrayList in the System.Collections namespace.
  • You can create your own generic interfaces, classes, methods, events and delegates.
  • Generic classes may be constrained to enable access to methods on particular data types.
  • Information on the types that are used in a generic data type may be obtained at run-time by using reflection.

转载于:https://www.cnblogs.com/cxchanpin/p/6919000.html

你可能感兴趣的文章
如何培养自己的管理才能?
查看>>
从App Store上获取已经上架的App版本信息
查看>>
SpringMvc实现日期转换
查看>>
Android稳定性测试之Log分析
查看>>
WPF中使用ObjectDataProvider绑定方法
查看>>
万能数据库查询分析器中文版本《DB查询分析器》几年来在“中关村在线”首次大榜小榜都能够榜上有名...
查看>>
孔明灯-噪点插画
查看>>
类与接口(三)java中的接口与嵌套接口
查看>>
VS关闭Browser Link
查看>>
【题解】山头狙击战
查看>>
USB小白学习之路(3) 通过自定义请求存取外部RAM
查看>>
Solr:通过solr admin对索引库维护<四>
查看>>
mysql写注释的几种方法
查看>>
UPC-2243 军事情报【递推】
查看>>
HTML常用标签查询
查看>>
四方精创前端开发面试经验
查看>>
软件测试作业(一)
查看>>
使用icomoon把svg图片生成字体图标
查看>>
C++中 使用数组作为map容器VAlue值的解决方法
查看>>
mysql left join,right join,inner join用法分析
查看>>