I have a line in my code:
var objects = ExternalApiGetObjects(....);
At develop time I only know that ExternalApiGetObjects
returns an Object
instance. In fact, I'm sure that objects
variable is an array of some type.
I want to pass objects
variable to String.Join
method, but in runtime I got an exception similar to this: "Object of type 'System.Int32[]' cannot be converted to type 'System.String[]'."
In most cases, an objects
will not be a string array. It could be an int array, or even an array of some user's type. I just know that objects is an array and I want to invoke ToString()
on each item of that array to create a new one with type of string[]
.
How can I convert my objects
to string[]
?