Advertisement
csaki

Lambda example

Apr 17th, 2014
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.60 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace interfaces
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             Random rand = new Random();
  13.             Stack<int> numbers = new Stack<int>();
  14.             for (int i = 0; i < 100; i++)
  15.             {
  16.                 numbers.Push(rand.Next(100));
  17.             }
  18.             // Where x (can be named any) greater than 50, it sums them together
  19.             Console.WriteLine(numbers.Where(x => x > 50).Sum());
  20.             Console.ReadLine();
  21.         }
  22.  
  23.  
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement