foreach(Object obj in object[])
{
   arrayList.add(obj);
}
做这样一个转换不就可以了

解决方案 »

  1.   

    object[] yourArray;
    ...ArrayList list = new ArrayList(yourArray);
      

  2.   

    object[] tt = new Object[]{1, 2, 4, 5, 6};
    System.Collections.ArrayList ar = new System.Collections.ArrayList(tt);
    MessageBox.Show(ar[0].ToString());
      

  3.   

    那再麻烦各位,如何将arraylist转换成object[]呢?
      

  4.   

    ArrayList list;
    ...object[] array = list.ToArray();
      

  5.   

    不好意思,再问一个问题,就是我现在的架构是winapp+webservice+server;现在是在winapp上做一个查询,要返回多条记录;我用的是arraylist来作为返回植,现在的问题是我在winapp端上调用一条查询命令,通过webservice在server上查询,但现在总是报错:错误如下:
    未处理的“System.Web.Services.Protocols.SoapException”类型的异常出现在 system.web.services.dll 中。其他信息: 服务器无法处理请求。 --> 生成 XML 文档时出错。 --> 不应是类型 ValueObject.ProcVO。使用 XmlInclude 或 SoapInclude 属性静态指定非已知的类型。
    这是为什么呀,是不是因为soap不支持传arraylist呀???各位大虾们救命呀!!!!
      

  6.   


    1.从object[] 到arraylist []
        object[] objColl = new Object[]{1, 2, 4, 5, 6};
        Arraylist []arrayList = new Arraylist[5];foreach(object obj in objColl )
    {
    arrayList.Add(obj);
    }2.从arraylist [] 到object[]object[] objColl = new Object[];
    Arraylist []arrayList = new Arraylist[5];
    for(int nCount = 0 ; nCount< 5 ;nCount++)
    {
    arrayList.Add(nCount);
    }for(int n = 0 ; n< 5 ;n++)
    {
    objectColl[n] =  arrayList [n];
    MessageBox.Show(objectColl[n].ToString());
    }