Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- LINQ
- int[] numbers = new int[7] { 0, 1, 2, 3, 4, 5, 6 };
- var numQuery =
- from num in numbers
- where (num % 2) == 0
- select num;
- foreach (int num in numQuery)
- {
- Console.Write("{0,1} ", num);
- }
- ---------------
- List<Student> studentList;
- studentList =
- new List<Student> {
- new Student { ID = 1, Name = "Tornike", Surname = "Kipiani", Country = "Georgia", Scholarship = 1 },
- new Student { ID = 2, Name = "Giorgi", Surname = "Tchkadua", Country = "USA", Scholarship = 500 },
- new Student { ID = 3, Name = "Nika", Surname = "Begoidze", Country = "Georgia", Scholarship = 0 }
- };
- var studentsQuery = from st in studentList
- where st.Country == "Georgia"
- select new { st.Country, st.ID, st.Name, st.Surname };
- foreach (var stud in studentsQuery)
- label1.Text = label1.Text + " , " + stud.ToString();
- ----------------
- DataContext db = new DataContext(@"c:\tornike.mdf");
- =============================================================
- 1) 5
- 2) 2
- 3) 4
- 4) 5
- 5) 3
- 6) 4
- 7) 1
- 8) 1
- 9) 2
- 10) 3
- 11) 3
- 12) 4
- 13) 4
- 14) 1
- 15) 2,3
Advertisement
Add Comment
Please, Sign In to add comment