本文介绍了如何在列表上迭代&lt; Object&gt;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 亲爱的所有人, hii我是c#中的新人我想知道如何迭代List< object>给我具体的输出数据 ex Dear All,hii iam new in c# an i want to know How can i iterate on List<object> to give me specific output dataexList<object> sParameterValues ;where:sParameterValues [0]=[1,2,3];sParameterValues [1]=["test","new","11"];sParameterValues [2]=["value","pla"]; . .sParameterValues [n]=["test3","pla","val2"];the out put that i need1 ^"test" ^"value" ^......n ^ "test3" , 2 ^"new" ^"pla" ^......n ^ "pla" ,3^"11"^" "^......n ^"val2" 谢谢thanks推荐答案 List<object> sParameterValues = new List<object>(4); sParameterValues.Add( new int[] { 1, 2, 3 }) ; sParameterValues.Add( new string[] { "test", "new", "11" });sParameterValues.Add( new string[] { "value", "pla" });sParameterValues.Add( new string[] { "test3", "pla", "val2" }); var intArray = sParameterValues[0] as int[]; for (int i = 0; i < intArray.Length; i++) { string content = intArray[i] + " -> "; for (int j = 1; j < sParameterValues.Count; j++) { string[] temp = sParameterValues[j] as string[]; if (temp.Length > i) content += temp[i] + " "; } System.Console.WriteLine(content); } System.Console.ReadLine(); 这篇关于如何在列表上迭代&lt; Object&gt;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-18 10:28