Skip to main content

What is the purpose of the params keyword?

Mid C#
Quick Answer params lets you pass a variable number of arguments without wrapping them in an array. The method receives them as an array, but callers write Sum(1, 2, 3) instead of Sum(new int[] { 1, 2, 3 }). Must be the last parameter in the signature, and only one params per method.

Answer

The params keyword allows passing a variable number of arguments to a method without explicitly creating an array.

S
SugharaIQ Editorial Team Verified Answer

This answer has been peer-reviewed by industry experts holding senior engineering roles to ensure technical accuracy and relevance for modern interview standards.

Want to bookmark, take notes, or join discussions?

Sign in to access all features and personalize your learning experience.

Sign In Create Account

Source: SugharaIQ

Ready to level up? Start Practice