zoukankan
html css js c++ java
IEnumerable
IEnumerator
Code
1
using
System;
2
using
System.Collections.Generic;
3
using
System.Linq;
4
using
System.Text;
5
using
System.Collections;
6
7
namespace
ConsoleApplication2
8
{
9
public
class
ListBoxList : IEnumerable
<
string
>
10
{
11
private
string
[] strings;
12
private
int
ctr
=
0
;
13
//
Enumerable class can return an enumerator
14
public
IEnumerator
<
string
>
GetEnumerator()
15
{
16
foreach
(
string
s
in
strings)
17
{
18
yield
return
s;
19
}
20
}
21
//
Explicit interface implemention
22
IEnumerator IEnumerable.GetEnumerator()
23
{
24
return
GetEnumerator();
25
}
26
//
initialize the listbox with string
27
public
ListBoxList(
params
string
[] initialString)
28
{
29
strings
=
new
String[
8
];
30
//
copy the strings passed into the constructor
31
foreach
(
string
s
in
initialString)
32
{
33
strings[ctr
++
]
=
s;
34
}
35
}
36
//
add a single string to the end of the listbox
37
public
void
Add(
string
theString)
38
{
39
strings[ctr]
=
theString;
40
ctr
++
;
41
}
42
//
allow array-like access
43
public
string
this
[
int
index]
44
{
45
46
get
47
{
48
if
(index
<
0
||
index
>=
strings.Length)
49
{
50
//
handle the index
51
}
return
strings[index];
52
}
53
set
54
{
55
strings[index]
=
value;
56
}
57
}
58
//
publish howmany strings you holds
59
public
int
GetEnmEntries()
60
{
61
return
ctr;
62
}
63
}
64
class
Program
65
{
66
static
void
Main(
string
[] args)
67
{
68
//
create a new listboxlist and initalize
69
ListBoxList lbt
=
new
ListBoxList(
"
hello
"
,
"
world
"
);
70
lbt.Add(
"
Who
"
);
71
lbt.Add(
"
Is
"
);
72
lbt.Add(
"
Douglas
"
);
73
lbt.Add(
"
Adams
"
);
74
string
subst
=
"
Universe
"
;
75
lbt[
1
]
=
subst;
76
//
accexx the listboxlist
77
foreach
(
string
s
in
lbt)
78
{
79
Console.WriteLine(s);
80
}
81
82
Console.ReadKey();
83
}
84
}
85
}
86
查看全文
相关阅读:
Java发送HTTP的Get 和 Post请求
vue 中使用 Ant Design 依次提供了三级选项卡
Postman中不为人知的秘密 之 设置全局变量,token
vue组件之间传值(03)__兄弟组件传值,事件总线[ EventBus ]
元素内部滚动到底部和顶部的监听
如何将三个数的颜色色值兼容成六个数的方法
前端内容的自动化构建
模拟vue实现简单的webpack打包
VXcode学习
npm install 成功安装依赖后,运行跑不起来怎么办?
原文地址:https://www.cnblogs.com/binlyzhuo/p/1433025.html
最新文章
React 使用antd 清空表单
新浪新闻API
vue题目
Vue的双向数据绑定原理是什么?
leetcode每日一题(2020-06-10):9.回文数
leetcode每日一题(2020-06-08):990. 等式方程的可满足性
leetcode每日一题(2020-06-07)126. 单词接龙 II
leetcode每日一题(2020-06-06):128. 最长连续序列
leetcode每日一题(2020-06-02):面试题64. 求1+2+…+n
leetcode每日一题(2020-06-03):837. 新21点
热门文章
leetcode每日一题(2020-06-04):238. 除自身以外数组的乘积
leetcode每日一题(2020-06-05):面试题29. 顺时针打印矩阵
leetcode每日一题(2020-05-31):101.对称二叉树
leetcode每日一题(2020-05-29):198.打家劫舍
手机通过USB共享网络
vue 中 meta 元数据使用和页面中title处理,登录login判断处理
js 遍历对象forEach is not a function [DOM集合--类数组对象转化为数组 ]
HTML中添加meta元数据内容
Visual Studio Code 快速生成HTML结构
slot-scope="scope" 插槽获取当前对象
Copyright © 2011-2022 走看看