Answers for "foreach in arraylist c#"

C#
0

foreach in arraylist c#

foreach (object __o in list) {
    string s = (string)__o;
    // loop body
}
Posted by: Guest on June-24-2021
0

foreach in arraylist c#

ArrayList x=new ArrayList();
x.Add(10);
x.Add("SS");

IEnumerator enumerator = (x).GetEnumerator();
try {
   while (enumerator.MoveNext()) {
      string element = (string)enumerator.Current; // here is casting occures
      // loop body;
   }
}
finally {
   IDisposable disposable = enumerator as System.IDisposable;
   if (disposable != null) disposable.Dispose();
}
Posted by: Guest on June-24-2021

C# Answers by Framework

Browse Popular Code Answers by Language