Parsing an array in C #

I am connecting to an external web service that is implemented using Apache Axis and SOAP 1.2. The web service returns an array with jagged objects, similar to the one below. Looking at XML, I have xsi: type = "soapenc: Array"

What will be the cleanest / best method for analyzing this array in C # 2 and C # 3, respectively? (I am particularly interested in C # 2, so the C # 3 solution will be interesting.)

- obj object [] {object [] []}

 - [0] object {object []}
  - [0] object {string}
  - [1] object {string}

 - [1] object {object []}
  - [0] object {string}
  - [1] object {bool}

 - [2] object {object []}
  - [0] object {string}
  - [1] object {object []}
   - [0] object {object [] []}
    - [0] object []
     - [0] object {string}
     - [1] object {string)
+3
1

, , . , , . .

    _array = new object[3];
    _result = new StringBuilder();

    //Populate array here

    foreach (object item in _array)
    {
         ParseObject(item);
    }


    private void ParseObject(object value)
    { 
        if (value.GetType().IsArray)
        {
            IEnumerable enumerable = value as IEnumerable;

            foreach (object item in enumerable)
            {                    
                ParseObject(item);
            }                
        }
        else
        {
            _result.Append(value.ToString() + "\n");
        }
    }
+1

Source: https://habr.com/ru/post/1729919/


All Articles