fork download
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace Examples {
  5.  
  6. class Geeks {
  7.  
  8. // function containing params parameters
  9. public static int Add(params int[] ListNumbers)
  10. {
  11. int total = 0;
  12.  
  13. // foreach loop
  14. foreach(int i in ListNumbers)
  15. {
  16. total += i;
  17. }
  18. return total;
  19. }
  20.  
  21. // Driver Code
  22. static void Main(string[] args)
  23. {
  24. var a = new List<int>() {1,2,3,4,5};
  25. int y = Add(a.ToArray());
  26.  
  27. // Displaying result
  28. Console.WriteLine(y);
  29. }
  30. }
  31. }
Success #stdin #stdout 0.02s 15936KB
stdin
Standard input is empty
stdout
15