/
aprogrammer
/
dotnet-docs
Обзор
Документация
Войти
/
aprogrammer
/
dotnet-docs
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
samples/snippets/csharp/VS_Snippets_VBCSharp/CsCsrefQueryKeywords/CS/Common.cs
30 строк
1 KB
Bill Wagner
Use Collection expressions for all language reference samples (#37993)
16 ноя 2023, 23:06
Не верифицирован
16 ноя 2023, 23:06
ace7aec
Код
Авторство
О чём код?
namespace CommonTypes; public class Common { // The element type of the data source public class Student { public required string First { get; init; } public required string Last { get; init; } public required int ID { get; init; } public required List<int> Scores; } public static List<Student> GetStudents() { // Use a collection initializer to create the data source. Note that each element // in the list contains an inner sequence of scores. List<Student> students = [ new Student {First="Svetlana", Last="Omelchenko", ID=111, Scores= [97, 72, 81, 60]}, new Student {First="Claire", Last="O'Donnell", ID=112, Scores= [75, 84, 91, 39]}, new Student {First="Sven", Last="Mortensen", ID=113, Scores= [88, 94, 65, 85]}, new Student {First="Cesar", Last="Garcia", ID=114, Scores= [97, 89, 85, 82]}, new Student {First="Debra", Last="Garcia", ID=115, Scores= [35, 72, 91, 70]} ]; return students; } }