https://msdn.microsoft.com/en-us/library/kwtft8ak(v=vs.140).aspx

It is often useful to define interfaces either for generic collection classes, or for the generic classes that represent items in the collection.

The preference偏爱,优先权 for generic classes is to use generic interfaces, such as IComparable<T> rather than IComparable, in order to avoid boxing and unboxing operations on value types.

The .NET Framework class library defines several generic interfaces for use with the collection classes in theSystem.Collections.Generic namespace.

When an interface is specified as a constraint约束 on a type parameter, only types that implement the interface can be used.

The following code example shows SortedList<T> class that derives from the GenericList<T> class.

For more information, see Introduction to Generics (C# Programming Guide).

SortedList<T> adds the constraint where T : IComparable<T>.

This enables the BubbleSort method in SortedList<T> to use the generic CompareTo method on list elements.

In this example, list elements are a simple class, Person, that implements IComparable<Person>.

Generic Interfaces (C# Programming Guide)的更多相关文章

  1. Interfaces (C# Programming Guide)

    https://msdn.microsoft.com/en-us/library/ms173156.aspx An interface contains definitions for a group ...

  2. Polymorphism (C# Programming Guide)

    https://msdn.microsoft.com/en-us/library/ms173152.aspx Polymorphism is often referred to as the thir ...

  3. 【IOS笔记】View Programming Guide for iOS -1

    原文:View Programming Guide for iOS View and Window Architecture Views and windows present your applic ...

  4. View Programming Guide for iOS ---- iOS 视图编程指南(五)---Animations

      Animations Animations provide fluid visual transitions between different states of your user inter ...

  5. View Programming Guide for iOS ---- iOS 视图编程指南(三)---Windows

    Windows Every iOS application needs at least one window—an instance of the UIWindow class—and some m ...

  6. View Programming Guide for iOS ---- iOS 视图编程指南(二)---View and Window Architecture

    View and Window Architecture 视图和窗口架构 Views and windows present your application’s user interface and ...

  7. [IoLanguage]Io Programming Guide[转]

    Io Programming Guide     Introduction Perspective Getting Started Downloading Installing Binaries Ru ...

  8. View Programming Guide for iOS_读书笔记[正在更新……]

    原文:View Programming Guide for iOS 1 Introduction 先熟悉一下基本概念. Window Windows do not have any visible c ...

  9. View Controller Programming Guide for iOS---(五)---Resource Management in View Controllers

    Resource Management in View Controllers View controllers are an essential part of managing your app’ ...

随机推荐

  1. jmeter接口测试小结

    摘自:http://www.cnblogs.com/houzhizhe/p/6839736.html JMeter做http接口压力测试 测前准备 用JMeter做接口的压测非常方便,在压测之前我们需 ...

  2. oracle中的冷热备份

    oracle有四种备份方法:冷备份.热备份.RMAN备份.逻辑备份. 其中冷备份和热备份都是用操作系统命令对oracle文件直接进行拷贝, 不同的是冷备份是把数据库关闭后再备份,备份过程中也要关闭数据 ...

  3. Java之三大基础排序(冒泡、选择、插入)

    注:以下排序均为从小到大 一.冒泡排序 package com.yunche.testsort; import java.util.Arrays; /** * @ClassName: BubbleSo ...

  4. linux shell脚本学习笔记一

    一.文件比较运算符-e filename 如果 filename存在,则为真 [ -e /var/log/syslog ]-d filename 如果 filename为目录,则为真 [ -d /tm ...

  5. java 十五周总结

  6. Django DTL模板语法中的过滤器

    template_filter_demo 过滤器相关: 一.形式:小写{{ name | lower }} 二.串联:先转义文本到HTML,再转换每行到 <p> 标签{{ my_text| ...

  7. HDU 1423 最长上升公共子序列(LCIS)

    题目大意: 给定两个数字数组a[] , b[],在这两个数组中找一个最长的公共上升子序列,输出最长的长度 从别人地方copy的= = LCIS理解: (1)f[i][j] 表示 a的前i,和b串前 j ...

  8. Drools介绍与使用

    Drools 是用 Java 语言编写的开放源码规则引擎,使用 Rete 算法对所编写的规则求值.Drools 允许使用声明方式表达业务逻辑.可以使用非 XML 的本地语言编写规则,从而便于学习和理解 ...

  9. org.apache.maven.archiver.MavenArchiver.getManifest(org.apache.maven.project.MavenProject, org.apach

    https://www.cnblogs.com/wxymg/p/8630471.html

  10. C - How Many Tables 并查集

    Today is Ignatius' birthday. He invites a lot of friends. Now it's dinner time. Ignatius wants to kn ...