Jul 29, 2012

Linq sample program with C#.net to change upper case to given string

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;
// need to add Linq sample
using System.Linq;

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

        private void button1_Click(object sender, EventArgs e)
        {


            var word1 = from word in "hi this is vamsi testing linq".Split() orderby word.Length descending select word.ToUpper();


//.ToUpper() -- for upper case output
//.ToLower()  -- for lower case output 

            foreach (string w1 in word1)
            {
                MessageBox.Show(w1);
            }
        }
    }
}


The Output will be  like
TESTING
VAMSI
KINQ
 THIS
IS
HI

No comments:

Post a Comment