C#程序遍历数组A中所有元素

string[] A = new string[5] { "a1","a2","a3","a4","a5"}; 

//第一种方法 

for (int i = 0; i < A.Length; i++) 
{ 
Console.WriteLine(A[i]); 
} 

//第二种方法 
IEnumerator e= A.GetEnumerator(); 
while (e.MoveNext()) 
{ 
Console.WriteLine(e.Current.ToString()); 
} 

//第三种方法 
foreach (string s in A) 
{ 
Console.WriteLine(s); 
}
原文地址:https://www.cnblogs.com/jsplyy/p/4265584.html