Pro EP 53:How to create a method with varying number of parameters in C# ?

Muhammad Waseem
Become .NET Pro !
Aug 21, 2023

We can achieve this by adding params keyword in our method.

- It only works for single dimensional array
- We can pass N number of params
- Only one param keyword is allowed in method
- If you send no arguments, the length of the params list is zero
- A comma-separated list of arguments of the type of the array elements

Whenever you’re ready, there are 4 ways I can help you

  1. Subscribe to my Weekly .NET Newsletter of C#/.NET with 7000+ Software Engineers.
  2. Promote yourself to 7000+ subscribers by Sponsoring my Newsletter
  3. Download my eBook at Gum Road which contains 30+ .NET Tips (With 2800+ Downloads)
  4. To get 100+ free and paid resources for learning C# and .NET visit this GitHub Repository

--

--