Mega Code Archive

 
Categories / C# Tutorial / LINQ
 

Use function in where clause

using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; public class MainClass{    public static void Main(string[] args){             String[] QueryString = { "One", "Two", "Three", "Four", "Five",               "Six", "Seven", "Eight", "Nine", "Ten" };          var ThisQuery = from StringValue in QueryString              let IndexValue = StringValue.Substring(0, 1)             where Convert.ToChar(IndexValue) > 'F'             orderby IndexValue             select new {StringValue, IndexValue};          foreach (var ThisValue in ThisQuery)             Console.WriteLine(ThisValue.IndexValue + " - " + ThisValue.StringValue);    } }