我在访问了不同的网站,以了解使用习俗统计的实际时间例子后,就放弃了这一界限。 我举几个例子。 但是,它们给我造成了混乱。
<><>Example>
<><0>
class NumberArray
{
public int[] scores;
public NumberArray()
{
}
public NumberArray(int[] scores)
{
this.scores = scores;
}
public int[] Scores
{
get {return scores;}
}
}
www.un.org/Depts/DGACM/index_spanish.htm 第2条:
public class Enumerator : IEnumerator
{
int[] scores;
int cur;
public Enumerator(int[] scores)
{
this.scores = scores;
cur = -1;
}
public Object Current
{
get {
return scores[cur];
}
}
public void Reset()
{
cur = -1;
}
public bool MoveNext()
{
cur++;
if (cur < scores.Length)
return true;
else return false;
}
}
public class Enumerable : IEnumerable
{
int[] numbers;
public void GetNumbersForEnumeration(int[] values)
{
numbers = values;
for (int i = 0; i < values.Length; i++)
numbers[i] = values[i];
}
public IEnumerator GetEnumerator()
{
return new Enumerator(numbers);
}
}
http://www.ohchr.org。
static void Main()
{
int[] arr = new int[] { 1, 2, 3, 4, 5 };
NumberArray num = new NumberArray(arr);
foreach(int val in num.Scores)
{
Console.WriteLine(val);
}
Enumerable en = new Enumerable();
en.GetNumbersForEnumeration(arr);
foreach (int i in en)
{
Console.WriteLine(i);
}
Console.ReadKey(true);
}
In take 2, I followed the custom iteration to iterate the same integer array as I did in take 1. Why should I beat about the bush to iterate an integer by using custom iteration?
或许,我忽略了实时定制中程>需要。 您能否解释一下我可以与现有回收设施做些什么? (I 刚刚结束学业,因此给我一个简单的例子,以便我能够适当理解。
Update : I took those examples from some site. There is nothing special in that code, we can achieve it very simply even without using custom iteration, my interest was to know the real scenario where custom iteration is quite handy.