fork download
  1. using static System.Console;
  2.  
  3. public class Exemplo {
  4. public static void Main() {
  5. UseParams(1, 2, 3, 4);
  6. UseParams(1);
  7. UseParams();
  8. UseParams(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
  9. UseParams2("lista", 1, 2, 3, 4);
  10. }
  11. public static void UseParams(params int[] list) {
  12. foreach (var item in list) Write(item + " ");
  13. WriteLine();
  14. }
  15. public static void UseParams2(string text, params int[] list) {
  16. Write(text + ": ");
  17. foreach (var item in list) Write(item + " ");
  18. WriteLine();
  19. }
  20. }
  21.  
  22. //https://pt.stackoverflow.com/q/119086/101
Success #stdin #stdout 0.02s 15800KB
stdin
Standard input is empty
stdout
1 2 3 4 
1 

1 2 3 4 5 6 7 8 9 10 
lista: 1 2 3 4