C# object to array

前端 未结 5 1541
失恋的感觉
失恋的感觉 2020-12-15 04:40

Using reflection I have an object which I need to cast into an iterable list of items (type unknown, will be object). Using the Watch window I can see my object is an array

5条回答
  •  既然无缘
    2020-12-15 04:48

    Simply Try This

     string[] arr = ((IEnumerable)yourOjbect).Cast()
                                 .Select(x => x.ToString())
                                 .ToArray();
    
        

    提交回复
    热议问题