C#接口类型
接口定义属性,方法和事件,它们是接口的成员。接口仅包含成员的声明。
C#中的某些接口类型包括。
IEnumerable-所有通用集合的基本接口。
IList-由数组和列表类型实现的通用接口。
IDictionary-词典集合。
IEnumerable是定义单个方法GetEnumerator的接口,该方法返回IEnumerator接口。
这适用于对实现IEnumerable可以与foreach语句一起使用的集合的只读访问。
下面显示了IEnumerable接口的实现。
示例
class Demo : IEnumerable, IEnumerator {
// IEnumerable method GetEnumerator() IEnumerator IEnumerable.GetEnumerator() {
throw new NotImplementedException();
}
public object Current {
get { throw new NotImplementedException(); }
}
//IEnumertor方法
public bool MoveNext() {
throw new NotImplementedException();
}
//IEnumertor方法
public void Reset() {
throw new NotImplementedException();
}
}在上面可以看到IEnumerator的两种方法。
// IEnumerator method
public bool MoveNext() {
throw new NotImplementedException();
}
//IEnumertor方法
public void Reset() {
throw new NotImplementedException();
}热门推荐
3 入学校简短祝福语
7 初八的祝福语简短
10 写给兄弟的祝福语简短
11 老婆生日祝福语简短孩子
12 贺寿祝福语长辈简短
13 出院祝福语简短8字
14 春节送祝福语简短的
15 父亲简短结婚祝福语大全
16 冬季祝福语大全 简短的
17 孩子满月随礼简短祝福语
18 生日祝福语短句简短霸气