Advertisement
Guest User

Untitled

a guest
Jan 24th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.79 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace lab10
  5. {
  6.     internal class Program
  7.     {
  8.         public static void Main(string[] args)
  9.         {
  10.             var l = new List<Vedomost>();
  11.             l.Add(new Vedomost("Name1", 4));
  12.             l.Add(new Vedomost("Name2", 3));
  13.             l.Add(new Vedomost("Name3", 5));
  14.             l.Sort(((vedomost, vedomost1) => vedomost.Mark.CompareTo(vedomost1.Mark)));
  15.             foreach (var vedomost in l)
  16.             {
  17.                 Console.WriteLine(vedomost.Name);
  18.             }
  19.            
  20.         }
  21.     }
  22.  
  23.     public class Vedomost
  24.     {
  25.         public int Mark;
  26.         public string Name;
  27.  
  28.         public Vedomost(string name, int mark)
  29.         {
  30.             Mark = mark;
  31.             Name = name;
  32.         }
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement