Tutorialspoint

C# handling empty collections

using System;
using System.Linq;
using System.Collections.Generic;

class Demo {
   static void Main() {
      List<float> myList = new List<float>();
      var res = myList.DefaultIfEmpty();
      foreach (var a in res) {
         Console.WriteLine(a);
      }
   }
}

Advertisements
Loading...