Advertisement
andruhovski

LINQ Demo

Sep 28th, 2018
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.87 KB | None | 0 0
  1. static void Main(string[] args)
  2.         {
  3.             var points = new List<Point>();
  4.             points.Add(new Point
  5.             {
  6.                 X = 1,
  7.                 Y = 2
  8.             });
  9.             points.Add(new Point
  10.             {
  11.                 X = 0.5,
  12.                 Y = -0.25
  13.             });
  14.             points.Add(new Point
  15.             {
  16.                 X = 0.5,
  17.                 Y = 0.5
  18.             });
  19.             points.Add(new Point
  20.             {
  21.                 X = -1,
  22.                 Y = -2
  23.             });
  24.  
  25.             var points1 =
  26.                 from Point pt in points
  27.                 where ((pt.X * pt.X) + (pt.Y * pt.Y)) <=1
  28.                 orderby pt.Y descending
  29.                 select pt;
  30.  
  31.             foreach (var item in points1)
  32.             {
  33.                 Console.WriteLine("{0} {1}",item.X, item.Y);
  34.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement