Advertisement
Guest User

Untitled

a guest
Sep 15th, 2019
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace ConsoleApp1
  5. {
  6. class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10. ClassRoom A = new ClassRoom();
  11. A.students = new List<Student>();
  12. A.students.Add(new Student() { name = "小明" ,score = 100 });
  13. A.students.Add(new Student() { name = "小陳", score = 80 });
  14. A.students.Add(new Student() { name = "小華", score = 50 });
  15.  
  16. uint score = 50;
  17.  
  18. Console.WriteLine($"分數為{score}分的人是:" + A.students.Where(o=>o.score== score).ToList()[0].name);
  19. Console.WriteLine($"分數為{score}分的人是:" + A[score][0].name);//使用索引
  20.  
  21. }
  22.  
  23.  
  24.  
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement