Compare string start in CSharp
Description
The following code shows how to compare string start.
Example
/* w w w. j ava2 s . c o m*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
static void Main(string[] args)
{
string[] names = { "Zheng", "Smith", "Small" };
var queryResults =
from n in names
where n.StartsWith("S")
orderby n
select n;
foreach (var item in queryResults)
{
Console.WriteLine(item);
}
}
}
The code above generates the following result.