Advertisement
Guest User

Untitled

a guest
May 23rd, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.41 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3. using System.Linq;
  4.  
  5. namespace Event
  6. {
  7.  
  8.     public class Student
  9.     {
  10.         public string Album { get; set; }
  11.         public string Name { get; set; }
  12.         public double[] Scores { get; set; }
  13.         public override string ToString()
  14.         {
  15.             return "Student: " + Name + " album: " + Album + " oceny: " + string.Join(",", Scores);
  16.         }
  17.     }
  18.  
  19.     class MainClass
  20.     {
  21.         public static void Main(string[] args)
  22.         {
  23.             ArrayList arrList = new ArrayList();
  24.             arrList.Add(
  25.             new Student
  26.             {
  27.                 Album = "1",
  28.                 Name = "Malinowski",
  29.                 Scores = new double[] { 1.0, 2.5, 2.0, 1.5 }
  30.             });
  31.  
  32.             arrList.Add(
  33.             new Student
  34.             {
  35.                 Album = "2",
  36.                 Name = "Nowak",
  37.                 Scores = new double[] { 3.0, 3.5 }
  38.             });
  39.  
  40.             arrList.Add(
  41.             new Student
  42.             {
  43.                 Album = "3",
  44.                 Name = "Adamiak",
  45.                 Scores = new double[] { 4.0, 5.5 , 6.0}
  46.             });
  47.  
  48.             var query = from Student student in arrList
  49.                     where student.Scores.ToList().Average() > 3.0
  50.                         select student;
  51.  
  52.  
  53.             foreach (Student s in query)
  54.                 Console.WriteLine(s.ToString());
  55.  
  56.         }
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement