Jul 29, 2012

Simple Filtering using Lamda expression in Linq using C#.net




using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Linq;

namespace Linq_ex
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }


 //Simple Filtering using Lamda expression
private void button2_Click(object sender, EventArgs e)
        {
            var word1 = from word in "hi this is vamsi testing linq".Split() orderby word.Length descending select word;


            IEnumerable<string> test = System.Linq.Enumerable.Where(word1, n => n.Length >= 4);

            foreach (string n in test)
            {

                MessageBox.Show(n + "|");
            }

        }


Out put will be:



TESTING
VAMSI
LiNQ
THIS

No comments:

Post a Comment