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

This C# program calculates and displays an upper triangular matrix based on user input. Problem Statement: The program takes the...
This C# program serves as a demonstration of bitwise operators, which are fundamental operators used for manipulating individual bits in...
This C# program is designed to interchange or swap the columns of a matrix. A matrix is a two-dimensional array...