Export (0) Print
Expand All
Expand Minimize

Compiler Error CS0581

Visual Studio .NET 2003

Named arguments not allowed on attribute 'attribute'

Some attributes do not take named arguments.

The following sample generates CS0581:

// CS0581.cs
using System.Runtime.CompilerServices;

public class MyClass
{
   [IndexerName("xxx", namedarg=3)]   // CS0581
   // try the following line instead
   // [IndexerName("xxx")]
   public int this[int index]
   {
      get
      {
         return 0;
      }
   }

   public static void Main()
   {
   }
}
Show:
© 2014 Microsoft