LINQ Example - Basic idea on how to query using LINQ

Posted by Karthikanbarasan under LINQ category on | Points: 40 | Views : 2595
This code sample shows how to query usign LINQ

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Demo
class Program
static void Main(string[] args)
string[] namesList = { "AB", "AC", "BB", "BC", "CA", "CB", "DD", "DA", "ABC", "GD", "ED", "AA", "BD" };

var queryResult =
from n in namesList
where n.StartsWith("A")
select n;

Console.WriteLine("Names beginning with A:");

foreach (var item in queryResult)

Console.Write("press Enter to continue:");


Comments or Responses

Login to post response