Compiler Error C3155

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at Compiler Error C3155.

attributes are not allowed in a property indexer

An indexed property was declared incorrectly. For more information, see How to: Use Indexed Properties.

The following sample generates C3155.

// C3155.cpp  
// compile with: /clr /c  
using namespace System;  
ref struct R {  
   property int F[[ParamArray] int] {   // C3155  
   // try the following line instead  
   // property int F[ int] {   // OK  
      int get(int i) {   
         return 0;   
      }  
   }  
};  

Show: