daily pastebin goal
33%
SHARE
TWEET

Untitled

a guest Aug 10th, 2018 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using GunDemo.Guns;
  6.  
  7. namespace GunDemo
  8. {
  9.     public class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             foreach (var item in EnumerateBothConcat())
  14.                 Console.WriteLine(item);
  15.  
  16.             foreach (var item in EnumerateBothYield())
  17.                 Console.WriteLine(item);
  18.         }
  19.  
  20.         static IEnumerable<int> EnumerateBothConcat()
  21.         {
  22.             List<int> list1 = new List<int>() { 1, 2, 3 };
  23.             List<int> list2 = new List<int>() { 4, 5, 6 };
  24.  
  25.             return list1.Concat(list2);
  26.         }
  27.  
  28.         static IEnumerable<int> EnumerateBothYield()
  29.         {
  30.             List<int> list1 = new List<int>() { 1, 2, 3 };
  31.             List<int> list2 = new List<int>() { 4, 5, 6 };
  32.  
  33.             foreach (var item in list1)
  34.                 yield return item;
  35.  
  36.             foreach (var item in list2)
  37.                 yield return item;
  38.         }
  39.     }
  40. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top