using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication7
{
class Program
{
static void Main(string[] args)
{
string[] names = { "Sheldon", "Penny", "Rajesh", "Howard", "Leonard", "Bernadette", "Amy", "Bill" };
var queryResults =
from n in names
where n.StartsWith("B")
orderby n ascending
select n;
Console.WriteLine("Got");
foreach (var i in queryResults)
{
Console.WriteLine(i);
}
var queryResults2 = names.Where(n => n.StartsWith("P"));
foreach (var i in queryResults2)
{
Console.WriteLine(i);
}
var queryResults3 = names.Where(getResult);
foreach (var i in queryResults3)
{
Console.WriteLine(i);
}
Console.Read();
}
static public bool getResult(string n)
{
if (n.StartsWith("S"))
return true;
else
return false;
}
}
}