object[]
to string[]
will result in CastException
CS-W1075Casting a generic array of type object
to a string
array will always fail even if all the elements are strings. It is therefore recommended that you use a suitable and correct alternative such as System.Linq.Select
to convert the elements.
var arr = (string[]) new object[] {"s"};
var arr = (new object[] {"s"}).Select(s => (string)s).ToArray();