using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
public class MainClass{
public static void Main(string[] args){
List TestData = new List();
var ThisQuery = from TheData in TestData select TheData;
foreach (var ThisElement in ThisQuery.DefaultIfEmpty())
Console.WriteLine(ThisElement);
TestData.Add("One");
TestData.Add("Two");
TestData.Add("Three");
foreach (var ThisElement in ThisQuery.DefaultIfEmpty())
Console.WriteLine(ThisElement);
}
}
public static class MyStrings
{
public static IEnumerable DefaultIfEmpty(this IEnumerable source)
{
if (source.Count() > 0)
return source;
else
{
List DefaultValue = new List();
DefaultValue.Add("Empty");
return DefaultValue;
}
}
}