Converting a nullable type to a non nullable type
-
-
By nullable 2d array, I presume you mean an array containing double?s. So you want to convert double?[] to double[]... What happens if there is a null in there then?
Regards, Rob Philpott.
-
var nullableDoubles = new double?\[2\]\[\]; nullableDoubles\[1\] = new double?\[\]{null, 1.1, null, 1.2}; double\[\]\[\] nonNullableDoubles = nullableDoubles.Select(doubleArray=>{ if(doubleArray==null) return null; else return doubleArray.Where(doubleValue => doubleValue.HasValue).Cast<double>().ToArray();}).ToArray();
--EricDV Sig--------- Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peters
-
By nullable 2d array, I presume you mean an array containing double?s. So you want to convert double?[] to double[]... What happens if there is a null in there then?
Regards, Rob Philpott.
-
var nullableDoubles = new double?\[2\]\[\]; nullableDoubles\[1\] = new double?\[\]{null, 1.1, null, 1.2}; double\[\]\[\] nonNullableDoubles = nullableDoubles.Select(doubleArray=>{ if(doubleArray==null) return null; else return doubleArray.Where(doubleValue => doubleValue.HasValue).Cast<double>().ToArray();}).ToArray();
--EricDV Sig--------- Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peters
-
System.Linq
--EricDV Sig--------- Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peters