C# Error CS0758 – Both partial method declarations must use a params parameter or neither may use a params parameter

C# Error

CS0758 – Both partial method declarations must use a params parameter or neither may use a params parameter

Reason for the Error & Solution

Both partial method declarations must use a params parameter or neither may use a params parameter

If one part of a partial method specifies a params parameter, the other part must specify one also.

To correct this error

  1. Either add the params modifier in one part of the method, or remove it in the other.

Example

The following code generates CS0758:

using System;  
  
    public partial class C  
    {  
        partial void Part(int i, params char[] array);  
        partial void Part(int i, char[] array) // CS0758  
        {  
        }  
  
        public static int Main()  
        {  
            return 1;  
        }  
  
    }