C#

C#

Made by DeepSource

Casting a object[] to string[] will result in CastException CS-W1075

Bug risk
Critical

Casting 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.

Bad Practice

var arr = (string[]) new object[] {"s"};

Recommended

var arr = (new object[] {"s"}).Select(s => (string)s).ToArray();