using System;
using System.Collections.Generic;
using System.Linq;
namespace MyCompiler {
class Student{
public int StudentID;
public string StudentName;
public int Age;
}
class Program {
public static void Main(string[] args) {
Console.WriteLine("Hello world!");
IList<Student> studentList = new List<Student>() {
new Student() { StudentID = 1, StudentName = "John", Age= 13} ,
new Student() { StudentID = 2, StudentName = "Moin", Age = 21 } ,
new Student() { StudentID = 3, StudentName = "Bill", Age = 13 } ,
new Student() { StudentID = 4, StudentName = "Ram" , Age = 20} ,
new Student() { StudentID = 5, StudentName = "Ron" , Age = 15 }
};
var filterlist = from item in studentList
where item.Age > 12
select item.StudentName;
Console.WriteLine(String.Join(",",filterlist));
//ORDER BY
var filterlistOB = from item in studentList
orderby item.StudentName, item.Age descending
select new {item.StudentName,item.Age};
Console.WriteLine(String.Join(",\n",filterlistOB));
//GROUP BY
var filterlistGB = from item in studentList
group item by item.Age;
foreach(var ele in filterlistGB){
Console.WriteLine("Key is {0} ",ele.Key);
//each group has the colelction of other properties within
foreach(Student s in ele){
Console.WriteLine("Name of the student {0} ",s.StudentName);
}
}
//JOIN
IList<Standard> standardList = new List<Standard>() {
new Standard(){ StandardID = 1, StandardName="Standard 1"},
new Standard(){ StandardID = 2, StandardName="Standard 2"},
new Standard(){ StandardID = 3, StandardName="Standard 3"}
};
}
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: