IList<T> 和 ICollection<T>

最重要的一些类型

List<T>: Encapsulates[T], like array, but also provide with adding/removing elemnts

ReadOnlyCollection<T>: Read-only wrapper for lists

Collection<T>: Allow lists to be customized

ObservableCollection<T>: List with changes notifications

List<T>

What: List<T>是IList<T>的一种implementation

 + 

Can do:

IList<T> - access by index

IEnumerable<T> - foreach

ICoolection<T> - Collection initialzers

Array - All array can do

Collection<T>

是IList<T>的另一种Implementation

比如:我们建立一个list must only accept non-blank, non-null strings. 用List<T>就不成

方法:

如上图,Collection<T> encapsulate 了List<T>,其含有ICollection interface为其带来的Add()方法,和IList<T>的insert和this[index],但是这些方法都不可以重写。

幸运的是这些方法都会call底层的一个virtual方法,insertItem和setItem,我们可以重写这两个方法,从而 customize 我们的collection。

ObervableCollection<T>

主要是利用里面的CollectionChanged event, 其实他也是从Collection<T> customize出来的特殊类型,microsoft自己也经常用collection<T>做一些custmize的事情

C#中的Collection 3的更多相关文章

  1. Mybatis中的collection、association来处理结果映射

    前不久的项目时间紧张,为了尽快完成原型开发,写了一段效率相当低的代码. 最近几天闲下来,主动把之前的代码优化了一下:)   标签:Java.Mybatis.MySQL 概况:本地系统从另外一个系统得到 ...

  2. 优雅使用 illuminate/database 包中的 Collection

    优雅使用 illuminate/database 包中的 Collection 或许你很抵抗使用 Laravel , 但是你没有理由不喜欢使用 illuminate/database.这是一个 ORM ...

  3. java中集合Collection转list对象

    参考:java中集合Collection转list对象 首先我的需求是获取到购物车列表,购物车列表是一个Map对象,构造方法获取购物项,这里购物项是Collection对象 // 购物项集合,K商品I ...

  4. Mybatis中使用collection进行多对多双向关联示例(含XML版与注解版)

    Mybatis中使用collection进行多对多双向关联示例(含XML版与注解版) XML版本: 实体类: @Data @NoArgsConstructor public class Course ...

  5. ruby -- 进阶学习(十)自定义路由中:new, :collection和:member的区别

    学习链接:http://rubyer.me/blog/583/ RESTful风格的路由动词默认有7个(分别为:index, show, create, new, edit, update, dest ...

  6. java中的Collection集合类

    随着1998年JDK 1.2的发布,同时新增了常用的Collections集合类,包含了Collection和Map接口.而Dictionary类是在1996年JDK 1.0发布时就已经有了.它们都可 ...

  7. mybatis 中 foreach collection的三种用法

    foreach的主要用在构建in条件中,它可以在SQL语句中进行迭代一个集合. foreach元素的属性主要有 item,index,collection,open,separator,close. ...

  8. mybatis 中 foreach collection的三种用法(转)

    文章转自 https://blog.csdn.net/qq_24084925/article/details/53790287 oreach的主要用在构建in条件中,它可以在SQL语句中进行迭代一个集 ...

  9. java 中的Collection

    /* *一. Collection?-------->容器! * * 1.来源于java.util包 非常实用的数据结构! * *二. 方法? * * void clear()删除集合中所有元素 ...

  10. JAVA 中的 Collection 和 Map 以及相关派生类的概念

    JAVA中Collection接口和Map接口的主要实现类   Collection接口 Collection是最基本的集合接口,一个Collection代表一组Object,即Collection的 ...

随机推荐

  1. erl0007 - erlang 远程节点连接的两种方式

    启动连接:erl -setcookie abc -name xxx@192.168.x.x -remsh xxx@192.168.x.y 退出:ctrl + g,q 参考:http://www.cnb ...

  2. Linux Shell编程(3):数组

    http://snailwarrior.blog.51cto.com/680306/154704 BASH只支持一维数组,但参数个数没有限制.   声明一个数组:declare -a array (其 ...

  3. 凸优化简介 Convex Optimization Overview

    最近的看的一些内容好多涉及到凸优化,没时间系统看了,简单的了解一下,凸优化的两个基本元素分别是凸函数与凸包 凸集 凸集定义如下: 也就是说在凸集内任取两点,其连线上的所有点仍在凸集之内. 凸函数 凸函 ...

  4. Filling a Path 模式

    Filling a Path When you fill the current path, Quartz acts as if each subpath contained in the path ...

  5. 基于catalog 创建RMAN存储脚本

    --============================== -- 基于catalog 创建RMAN存储脚本 --============================== 简言之,将rman的 ...

  6. jQuery基础知识--Form基础

    form中的单行文本获取和失去焦点 <!DOCTYPE html> <html> <head lang="en"> <meta chars ...

  7. js四舍五入

    7-13 向上取整ceil() 7-14 向下取整floor() 7-15 四舍五入round() 7-16 随机数 random()

  8. java定时器的几种用法

    package com.lid; import java.util.Calendar; import java.util.Date; import java.util.Timer; import ja ...

  9. 解决oracle11g的ORA-12505问题

    今天在使用SQL Developer的时候连不上去,报ORA-12505错误,但是SQLPLUS可以连接. 检查服务名,是OracleServiceORCL,那SID应当就是orcl,但是使用该SID ...

  10. Maven安装testNG

    1.Maven安装testNG (1)打开网站:http://testng.org/doc/maven.html (2)复制如下代码,粘贴到项目的pom.xml文件: 1 <dependency ...