gabi11

Functional Programming - 1. Sort Even Numbers

May 25th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.59 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6.  
  7.  
  8. namespace CSharpAdvanced
  9. {
  10.     class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             var input = Console.ReadLine()
  15.                 .Split(new[] { ", "}, StringSplitOptions.RemoveEmptyEntries)
  16.                 .Select(int.Parse)
  17.                 .Where(x => x % 2 == 0)
  18.                 .OrderBy(x => x)
  19.                 .ToList();
  20.  
  21.             string result = string.Join(", ", input);
  22.  
  23.             Console.WriteLine(result);
  24.         }
  25.     }
  26. }
Add Comment
Please, Sign In to add comment