Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace ConsoleApp1
- {
- class Program
- {
- static void Main(string[] args)
- {
- ClassRoom A = new ClassRoom();
- A.students = new List<Student>();
- A.students.Add(new Student() { name = "小明" ,score = 100 });
- A.students.Add(new Student() { name = "小陳", score = 80 });
- A.students.Add(new Student() { name = "小華", score = 50 });
- uint score = 50;
- Console.WriteLine($"分數為{score}分的人是:" + A.students.Where(o=>o.score== score).ToList()[0].name);
- Console.WriteLine($"分數為{score}分的人是:" + A[score][0].name);//使用索引
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement