简体   繁体   中英

Couldn't convert an Object to an Array in C# [on hold]

I am trying to convert an Object to an Array. When I try to, the converted value sits as null. I am not able to understand why this is happening. Am I missing something?

string argName = argumentName + "1";
var holder = typeof(MyClass).GetProperty(argName);
object valueHolder = holder.GetValue(argName);
string[] test = valueHolder as string[]; //test sits as null where valueHolder seems to be intact.

I have attached screenshots during debugvalueHolder 完好无损 测试为空

I resolved this by having an int[] to hold.

int[] test1 = valueHolder as int[];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM