public static void TestForEach(ref int[] myArray)
foreach (int x in myArray)
public static void TestForWithLength(ref Object[] myArray)
for (int x = 0; x < myArray.Length; x++)
Console.WriteLine(myArray[x]);
public static void TestForEnum(ref System.Array myArray)
System.Collections.IEnumerator myEnumerator = myArray.GetEnumerator();
int cols = myArray.GetLength(myArray.Rank - 1);
while (myEnumerator.MoveNext())
Console.WriteLine(myEnumerator.Current);
public static void Main()
int[] myIntArray = new int[5]{5, 4, 3, 2, 1};
TestForEach(ref myIntArray);
Object[] myObjArray = new Object[5]{99, 98, 97, 96, 95};
TestForWithLength(ref myObjArray);
Array myObjArray2 = Array.CreateInstance(Type.GetType("System.Object"), 5);
for (int i = myObjArray2.GetLowerBound(0); i <= myObjArray2.GetUpperBound(0); i++)
myObjArray2.SetValue(i * i, i);
TestForEnum(ref myObjArray2);