CSharp examples for System:Array Null Element
Cuts away all null values from generic array
using System.Text; using System.Linq; using System.Collections.Generic; using System;//from www . j a v a 2s. com public class Main{ /// <summary> /// Cuts away all null values /// </summary> public static void PruneVals<T>(ref T[] arr) where T : struct { var list = new List<T>(arr.Length); foreach (var obj in arr) { if (!obj.Equals(default(T))) { list.Add(obj); } } arr = list.ToArray(); } }