Introducing Radical.sh

Forget Code launches a powerful code generator for building API's

IENUMERABLE - Passing as an argument in C#

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace ForgetCode
  6. {
  7. public class MainClass
  8. {
  9. public static void Main()
  10. {
  11. Display(new List<bool> { true, false, false });
  12. }
  13.  
  14. static void Display(IEnumerable<bool> argument)
  15. {
  16. foreach (bool value in argument)
  17. {
  18. Console.WriteLine(value);
  19. }
  20.  
  21. }
  22. }
  23. }


In the above code, we are passing IEnumerable object reference to a method.
Output:
True
False
False