This documentation is archived and is not being maintained.

Compiler Error CS3006

Overloaded method 'method' differing only in ref or out is not CLS-compliant

A method does not cannot be overloaded based on the ref or out parameter and still comply with the Common Language Specification (CLS).

The following sample generates CS3006:

// CS3006.cs
using System;
[assembly: CLSCompliant(true)]

public class MyClass
{
   public void f(int i)
   {
   }

   public void f(ref int i)   // CS3006
   {
   }

   public static void Main()
   {
   }
}

To resolve this error, comment out the assembly-level attribute or remove one of the method definitions.

See Also

What Is the Common Language Specification

Show: