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;  
        }  
  
    }  

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

C# Compiler Error CS0442 – ‘Property’: abstract properties cannot have private accessors Reason for the Error You’ll get this error...
This is a really simple one . Below is a simple example of an enum called “Designation” defined with the...
This blog post explain the usage of the Checked Block in .NET and how you can use them in Visual...