How to Use Params Keyword in C#

Params Keyword in C#. Importance of Params Keyword in C#.

Hi Guy’s, Here is the article to explain Params keyword in C#.net.Here is the some points about Params Keyword. Let’s see.
we can denote a method parameter that accept a changeable number of arguments. we can pass a comma-separated values of arguments.

We can also pass no arguments to params list. If we pass no arguments, the length of the params parameter has zero. Suppose , If we pass two arguments to params list. then length of the params parameter has two. If three then three length. No further parameters are allowed after the params keyword used in a method declaration, one and only one params keyword is enough. we must use array data types with params keyword. without using array symbol []. it will show the errors.

  • C# Program Without Using Params Keyword and Method has two Parameters. Follow Below Picture.
  • C# Program Without Using Params Keyword and Method has three Parameters. Follow Below Picture.
  • C# Program Using Params Keyword and Method has different Parameters. Follow Below Picture.

The best benefit of using params keyword , one time use this method with integer or any others data types and array must include
then it can accepts various parameters.i hope guy’s this article helpful.

Happy Coding… Thanks.

Post Author: adama