public void RemoveBoat() { int[] result = Docks .Select((b, i) => b != null && b.Docked == false ? i : -1) .Where(i => i != -1) .ToArray(); foreach (var item in result) { Docks.SetValue(null, item); } Boats .RemoveAll(b => b != null && b.Docked == false); }