C# Compiler Error
CS0225 – The params parameter must be a single dimensional array
Reason for the Error
The params keyword in C# lets you specify a method argument that can take variable number of arguments. You will receive this error when you have not defined the single dimensional array as parameter for params type in the function.
For example, try to compile the below code snippet.
namespace DeveloperPubNamespace { class Program { public static void SetUserData(params int input) { } public static void Main() { SetUserData(1); } } }
This program will result with the error code CS0225 because C# compiler has detected that parameter input with params keyword is of type int instead of integer array.
Error CS0225 The params parameter must be a single dimensional array ConsoleApp3 C:\Users\SenthilBalu\source\repos\ConsoleApp3\ConsoleApp3\Program.cs 5 Active
Solution
To fix the error code CS0225 in C#, you’ll need to change the parameter type to array as shown below.
namespace DeveloperPubNamespace { class Program { public static void SetUserData(params int[] input) { } public static void Main() { SetUserData(1); } } }