讲解下迭代的含义跟算法吧,先谢了
解决方案 »
- C# Socket分包和拆包.自已仿着别人写了一个方法.可是比以前更慢了.效率也更低了.请高手指点!
- 关于DataGridView中RowCount的值
- 从SQL server 转换到 postgresql
- 自己写的类库在Reporting Services中调用出错??
- 关于update数据库的问题
- @@@@@关于任务栏图标问题 100分@@@@@@@
- 希望能得到大家的帮助谢谢。
- 当datagrid的某一行失去焦点时,我想触发一个事件,如何实现!
- 如何更改Active Directory中用户的密码?
- 我想在C#开发的Web Services中调用VB.net写的一段程序,应该如何调用啊?
- WinForm程序
- 急用 求用C# 编写的日程安排软件
迭代语句中使用下列关键字:
do
for
foreach
in
while举个例子:// Declare the collection:
public class SampleCollection
{
public int[] items; public SampleCollection()
{
items = new int[5] { 5, 4, 7, 9, 3 };
} public System.Collections.IEnumerable BuildCollection()
{
for (int i = 0; i < items.Length; i++)
{
yield return items[i];
}
}
}class MainClass
{
static void Main()
{
SampleCollection col = new SampleCollection(); // Display the collection items:
System.Console.WriteLine("Values in the collection are:");
foreach (int i in col.BuildCollection())
{
System.Console.Write(i + " ");
}
}
}
详细内容请参见:http://msdn.microsoft.com/zh-cn/library/65zzykke.aspx