I\'m using a linq query to output an int array. But I need to pass this into a method that only accepts int?[].
So after searching on ways to convert int[] to int?[] I
How about this using Cast<> and a type constraint making T a struct:
Cast<>
T
struct
public static IEnumerable ToArrayOrNull(this IEnumerable seq) where T : struct { if (seq.Count() == 0) return null; return seq.Cast().ToArray(); }