ASP.NET如何将转换为字符串的数组对象转换回数组

时间:2011-08-09 08:34:02

标签: asp.net vb.net

嘿,我有以下功能,

        Dim results() As Object = Me.Invoke("webdirect", New Object() {Company, LocationCode, CustomerNumber, OrderNumber, OrderRef, OrderDate, WebLines})
        o_Company = CType(results(1),System.Nullable(Of Integer))
        o_LocationCode = CType(results(2),String)
        o_CustomerNumber = CType(results(3),String)
        o_OrderNumber = CType(results(4),String)
        o_OrderStatus = CType(results(5),String)
        o_OrdDescrip = CType(results(6),String)
        RespLines = CType(results(7),webdirect_RespLinesRow())
        Return CType(results(0),String)

所以这个函数的返回类型是一个字符串,但我想把它恢复到原来的形式,这样我就可以访问各个部分,如o_LocationCode,o_CustomerNumber等,我该怎么做?

进一步编辑

整个功能看起来像这样

Public Function webdirect(<System.Xml.Serialization.XmlElementAttribute(IsNullable:=true)> ByVal Company As System.Nullable(Of Integer), <System.Xml.Serialization.XmlElementAttribute(IsNullable:=true)> ByVal LocationCode As String, <System.Xml.Serialization.XmlElementAttribute(IsNullable:=true)> ByVal CustomerNumber As String, <System.Xml.Serialization.XmlElementAttribute(IsNullable:=true)> ByVal OrderNumber As String, <System.Xml.Serialization.XmlElementAttribute(IsNullable:=true)> ByVal OrderRef As String, <System.Xml.Serialization.XmlElementAttribute(DataType:="date", IsNullable:=true)> ByVal OrderDate As System.Nullable(Of Date), <System.Xml.Serialization.XmlArrayAttribute(IsNullable:=true), System.Xml.Serialization.XmlArrayItemAttribute("WebLinesRow", IsNullable:=false)> ByVal WebLines() As webdirect_WebLinesRow, <System.Xml.Serialization.XmlElementAttribute(IsNullable:=true)> ByRef o_Company As System.Nullable(Of Integer), <System.Xml.Serialization.XmlElementAttribute(IsNullable:=true)> ByRef o_LocationCode As String, <System.Xml.Serialization.XmlElementAttribute(IsNullable:=true)> ByRef o_CustomerNumber As String, <System.Xml.Serialization.XmlElementAttribute(IsNullable:=true)> ByRef o_OrderNumber As String, <System.Xml.Serialization.XmlElementAttribute(IsNullable:=true)> ByRef o_OrderStatus As String, <System.Xml.Serialization.XmlElementAttribute(IsNullable:=true)> ByRef o_OrdDescrip As String, <System.Xml.Serialization.XmlArrayAttribute(IsNullable:=true), System.Xml.Serialization.XmlArrayItemAttribute("RespLinesRow", IsNullable:=false)> ByRef RespLines() As webdirect_RespLinesRow) As <System.Xml.Serialization.XmlElementAttribute("result", IsNullable:=true)> String

Dim results() As Object = Me.Invoke("webdirect", New Object() {Company, LocationCode, CustomerNumber, OrderNumber, OrderRef, OrderDate, WebLines})
o_Company = CType(results(1),System.Nullable(Of Integer))
o_LocationCode = CType(results(2),String)
            o_CustomerNumber = CType(results(3),String)
            o_OrderNumber = CType(results(4),String)
            o_OrderStatus = CType(results(5),String)
            o_OrdDescrip = CType(results(6),String)
            RespLines = CType(results(7),webdirect_RespLinesRow())
            Return CType(results(0),String)
        End Function

像这样打电话

        Dim returnArray As String

    returnArray = client.webdirect(10, "123", "123", "123", "147", "2011-11-1", webLinesArray, 10, "", "", "", "", "", webRespArray)

运行时没有错误,但字符串似乎只是空白,这就是为什么我想知道如何将字符串转换回数组,以便我可以访问各个元素。

1 个答案:

答案 0 :(得分:0)

你能直接退回阵列吗?

Return results