how to upcast object array to another type of object array in C#?

前端 未结 3 992
耶瑟儿~
耶瑟儿~ 2021-01-22 12:29

I want to upcast object array to different array of different object type like below

object[] objects; // assuming that it is non-empty

CLassA[] newObjects = obj

3条回答
  •  独厮守ぢ
    2021-01-22 13:22

    Or I guess you could try something like this for even shorter syntax:

    newObjects = objects.Cast().ToArray();
    

提交回复
热议问题