Hi friends
C# Tutorial
Part 39:
LINQ
www.siri-kt.blogspot.com
• LINQ(language integrated query):
• LINQ queries are used to filter the data and format the
data. LINQ queries Microsoft designed using "generic"
classes and with anonymous data types.
• anonymous datatype means it allows integer types, string
types and object types
• ex:
• int[] i={1,5,8,9,12,15,50,20,30};
• var x=from n in i where n>5 select n;
• select * from emp
• as per .NET technologies "var" is anonymous datatype.
• LINQ queries we can inherit to the object, ado.net and
to the xml.
• example on LINQ:(retrieving greater than 5 array values)
• 1.take the form
• 2.add listbox and one button control
• source code:
• private void button1_Click(object sender, EventArgs e)
• { int[] i = { 1, 22, 3, 8, 9, 15, 14, 16, 18 };
• var x = from n in i where n > 5 select n;
• foreach (var v in x)
• {
• listBox1.Items.Add(v.ToString());
• } }
• ex:
• retrieving Even numbers from the array list
• 1.take the form
• 2.add listbox and one button control
• source code:
• private void button1_Click(object sender, EventArgs e)
• { int[] i = { 1, 5, 6, 4, 7, 9, 11, 13, 15, 16 };
• var x = from n in i where n % 2 == 0 select n;
• foreach (var v in x)
• { listBox1.Items.Add(v.ToString());
• } }
• ex:
• string array elements arrange in ascending order:
• 1.take the form
• 2.add listbox and one button control
• source code:
• private void button1_Click(object sender, EventArgs e)
• { string[] nos = { "one", "two", "three", "four",
"five", "six", "seven", "eight", "nine", "ten" };
• var no = from n in nos orderby n ascending select n;
• foreach (var v in no)
• { listBox1.Items.Add(v.ToString());
• } }
For more visit our website www.siri-kt.blogspot.com
Thanks for
Watching
More Angular JS TutorialsMore C sharp (c#) tutorials

39c

  • 1.
    Hi friends C# Tutorial Part39: LINQ www.siri-kt.blogspot.com
  • 2.
    • LINQ(language integratedquery): • LINQ queries are used to filter the data and format the data. LINQ queries Microsoft designed using "generic" classes and with anonymous data types. • anonymous datatype means it allows integer types, string types and object types • ex: • int[] i={1,5,8,9,12,15,50,20,30}; • var x=from n in i where n>5 select n; • select * from emp • as per .NET technologies "var" is anonymous datatype. • LINQ queries we can inherit to the object, ado.net and to the xml.
  • 3.
    • example onLINQ:(retrieving greater than 5 array values) • 1.take the form • 2.add listbox and one button control • source code: • private void button1_Click(object sender, EventArgs e) • { int[] i = { 1, 22, 3, 8, 9, 15, 14, 16, 18 }; • var x = from n in i where n > 5 select n; • foreach (var v in x) • { • listBox1.Items.Add(v.ToString()); • } }
  • 4.
    • ex: • retrievingEven numbers from the array list • 1.take the form • 2.add listbox and one button control • source code: • private void button1_Click(object sender, EventArgs e) • { int[] i = { 1, 5, 6, 4, 7, 9, 11, 13, 15, 16 }; • var x = from n in i where n % 2 == 0 select n; • foreach (var v in x) • { listBox1.Items.Add(v.ToString()); • } }
  • 5.
    • ex: • stringarray elements arrange in ascending order: • 1.take the form • 2.add listbox and one button control • source code: • private void button1_Click(object sender, EventArgs e) • { string[] nos = { "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten" }; • var no = from n in nos orderby n ascending select n; • foreach (var v in no) • { listBox1.Items.Add(v.ToString()); • } }
  • 6.
    For more visitour website www.siri-kt.blogspot.com Thanks for Watching More Angular JS TutorialsMore C sharp (c#) tutorials