Listからnull要素をすべて削除する
まあ、条件次第だから指定の要素はnullじゃなくてもいいんだけど。
List(T).RemoveAll メソッド (System.Collections.Generic)
public class Sample { public static void Main() { List<string> sampleList = new List<string>(); sampleList.Add("ABC"); sampleList.Add("DEF"); sampleList.Add(null); sampleList.Add("GHI"); sampleList.Add(null); // nullを全部削除する sampleList.RemoveALL(MatchNullable); } private static bool MatchNullable(string s) { return (s == null) ? true : false; } }