How to generates an empty IEnumerable with zero elements in C#

1 Answer

0 votes
using System;
using System.Linq;

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            var empty = Enumerable.Empty<int>();

            Console.WriteLine(empty.Count());
        }
    }
}


/*
run:

0

*/

 



answered Mar 3, 2017 by avibootz
...