CSharp examples for System.Collections.Generic:List
Returns either the list or a new List if list is null.
using System.Reflection; using System.Linq; using System.Collections.Generic; using System;/*w ww .j av a 2s . c o m*/ public class Main{ /// <summary> /// Returns either the list or a new List if list is null. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="list"></param> /// <returns></returns> public static List<T> NotNull<T>(this List<T> list) { if (list == null) { list = new List<T>(); } return list; } }