Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

It's been a while since I studied programming and I'm struggling with this.

I receive from a web service a bunch of info, which I save on an object, then after using the reflection method I get arrays, so I'm still stuck on having arrays inside an object.

I just cant remember how to convert the arrays inside of the object to string arrays, can someone help me out?

object information = new object();
string propName="members";
information=sinos1.Info(Convert.ToInt32(edo),Convert.ToInt32(anio),Convert.ToInt64(familia));
Object value = GetPropValue( information, propName);

information is the object that receives the info from the web service and value is the object that receives the info after the reflection which code is:

public static object GetPropValue(object src, string propName)
{
     return src.GetType().GetProperty(propName).GetValue(src, null);
}
share|improve this question

1 Answer

up vote 0 down vote accepted

You can try to probe the object for interfaces.

object value = GetPropValue(information, propName);

if(value is IEnumerable)
{
    var array = value as IEnumerable;
    foreach(object obj in array)
    {

    }
}

Further you can use Type.GetTypeCode on the obj for handling value types.

share|improve this answer
I don't know if this may help out to help read whats on value, while debugging, this is what value type changes from object to: object {ScanIt.sinos2.Sinos_Integrante[]} this happens after reflection – elnashillo Apr 23 at 18:38

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.