Languages
[Edit]
EN

C# - multiple parameters in method

7 points
Created by:
Nabila-Burnett
385

In this short article, we would like to show how to pass multiple arguments to function in C#.

Quick solution:

 

1. Documentation

Edit

Simple case:

Definition syntax
Calling syntax
Description

By adding param keyword to function argument we are able to create function that accepts multiple arguments.

Using that construction it is required to:

  • use array type with that param argument,
  • put param argument always as last.

The number of total arguments depends on function calling.

Composed cases:

Definition syntax
Calling syntax

 

Practical example

Edit

In ths section you can see 2 example cases:

  • multiple arguments function,
  • normal arguments function extended with additional arguments.

Output:

 

References

Edit
  1. params (C# Reference) - Microsoft Docs

Alternative titles

  1. C# - multiple arguments in method
  2. C# - multiple parameters in function
  3. C# - multiple arguments in function
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join