Posted: 10/19/2010
Hello experts,
I was reading in 1 of the books yesterday. There I saw this code.This is a collection of objects in arraylist. in order to iterate the items they used the below code.
ArrayList arr = new ArrayList(); string s = "Hello I'm vij"; arr.Add(50); arr.Add(s); arr.Add("Hi Im Sumit"); arr.Add(new object()); arr.Insert(2, "Hi Im Ajit"); IEnumerator enumerator = arr.GetEnumerator(); while (enumerator.MoveNext()) { Response.Write(enumerator.Current); Response.Write("<br/>"); }
It was also written that the above code works internally in foreach loop. Is this how foreach loop works?
Thanks,
Sumit
SumitArora said: user="Sumit Arora"] Is this how foreach loop works?
user="Sumit Arora"] Is this how foreach loop works?
yes