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代码---------常用的方法indexOf()和substring()方法的小结、主要是下标都是从0开始,很重要,错了就那个差远了啊
java代码-----indexOf()方法--从字符串的某个字符的第一次出现的位子开始
java代码----substring()方法是按索引截取字符串。。。下标0开始
java代码啊==indexOf()方法返回字符第一次出现的位置
java代码------实现从控制台输入整型,
java代码----I/O流从控制台输入信息判断并抛出异常
(转)pip和easy_install使用方式
小小粉丝度度熊
P1613 跑路
P3819 松江1843路
原文地址:https://www.cnblogs.com/binlyzhuo/p/1433025.html
最新文章
html5 canvas 运行起来绝对让你震撼!
一个简单实用的图片切换小例子
html5 canvas 一个漫天飞雪的效果
解决全站ie6下PNG图片不透明问题只要几行代码
超好超全面的测试鼠标滚轮滚动事件案例
潭州课堂25班:Ph201805201 django 项目 第一课 (课堂笔记)
潭州课堂25班:Ph201805201 django框架 第十三课 自定义404页面,auth系统中的User模型,auth系统权限管理 (课堂笔记)
潭州课堂25班:Ph201805201 django框架 第十二课 自定义中间件,上下文处理,admin后台 (课堂笔记)
云服务器配置
潭州课堂25班:Ph201805201 django框架 第十一课 保持登录,注册,登录 (课堂笔记)
热门文章
潭州课堂25班:Ph201805201 django框架 第十课 GET,POST 请求 文件上传,HttpResponse,cookie (课堂笔记)
潭州课堂25班:Ph201805201 django框架 第九课 模型补充 博客小案例 (课堂笔记)
潭州课堂25班:Ph201805201 django框架 第八课 表关联对象方法add,create,remove,clear,多表查询 (课堂笔记)
潭州课堂25班:Ph201805201 django框架 第七课 常用 字段类型及参数,关系表的实现,表关系对象add,create的方法 (课堂笔记)
潭州课堂25班:Ph201805201 django框架 第六课 模型类增删改查,常用 的查询矣查询条件 (课堂笔记)
ZooKeeper 笔记
java代码--实现随机输出10个随机数,并显示最大值,最小值
java代码----对于数据类型Integer
java代码-----String数组进行排序。是英文的字符串
java代码-------继承的方法----重写还是重载
Copyright © 2011-2022 走看看