Return an Empty Sequence of Strings in CSharp

Description

The following code shows how to return an Empty Sequence of Strings.

Example


 /* w  ww . j a  v a 2 s .  c o  m*/
 
 
  
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

public class MainClass {
    public static void Main() {
        IEnumerable<string> strings = Enumerable.Empty<string>();
        foreach (string s in strings)
            Console.WriteLine(s); 
        Console.WriteLine(strings.Count());
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    LINQ »




Operator
Select
Where
OrderBy
Group
Join
Let
LINQ