C# Error CS0674 – Do not use ‘System.ParamArrayAttribute’. Use the ‘params’ keyword instead.

C# Error

CS0674 – Do not use ‘System.ParamArrayAttribute’. Use the ‘params’ keyword instead.

Reason for the Error & Solution

Do not use ‘System.ParamArrayAttribute’. Use the ‘params’ keyword instead.

The C# compiler does not allow for the use of ; use instead.

The following sample generates CS0674:

// CS0674.cs  
using System;  
public class MyClass
{  
  
   public static void UseParams([ParamArray] int[] list)   // CS0674  
   // try the following line instead  
   // public static void UseParams(params int[] list)
   {  
      for ( int i = 0 ; i < list.Length ; i++ )  
         Console.WriteLine(list[i]);  
      Console.WriteLine();  
   }  
  
   public static void Main()
   {  
      UseParams(1, 2, 3);  
   }  
}  

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...