C# Compiler Error Codes CS0501 to CS1000

In this post, you’ll learn all the C# compiler error and warnings from the code CS0501 to CS1000.

C# Compiler Error Codes CS0501 to CS1000

Error CodeTypeError/Warning Description
CS0501Error‘{0}’ must declare a body because it is not marked abstract, extern, or partial
CS0502Error‘{0}’ cannot be both abstract and sealed
CS0503ErrorThe abstract {0} ‘{1}’ cannot be marked virtual
CS0504ErrorThe constant ‘{0}’ cannot be marked static
CS0505Error‘{0}’: cannot override because ‘{1}’ is not a function
CS0506Error‘{0}’: cannot override inherited member ‘{1}’ because it is not marked virtual, abstract, or override
CS0507Error‘{0}’: cannot change access modifiers when overriding ‘{1}’ inherited member ‘{2}’
CS0508Error‘{0}’: return type must be ‘{2}’ to match overridden member ‘{1}’
CS0509Error‘{0}’: cannot derive from sealed type ‘{1}’
CS0513Error‘{0}’ is abstract but it is contained in non-abstract type ‘{1}’
CS0514Error‘{0}’: static constructor cannot have an explicit ‘this’ or ‘base’ constructor call
CS0515Error‘{0}’: access modifiers are not allowed on static constructors
CS0516ErrorConstructor ‘{0}’ cannot call itself
CS0517Error‘{0}’ has no base class and cannot call a base constructor
CS0518ErrorPredefined type ‘{0}’ is not defined or imported
CS0522Error‘{0}’: structs cannot call base class constructors
CS0523ErrorStruct member ‘{0}’ of type ‘{1}’ causes a cycle in the struct layout
CS0525ErrorInterfaces cannot contain instance fields
CS0526ErrorInterfaces cannot contain instance constructors
CS0527ErrorType ‘{0}’ in interface list is not an interface
CS0528Error‘{0}’ is already listed in interface list
CS0529ErrorInherited interface ‘{1}’ causes a cycle in the interface hierarchy of ‘{0}’
CS0533Error‘{0}’ hides inherited abstract member ‘{1}’
CS0534Error‘{0}’ does not implement inherited abstract member ‘{1}’
CS0535Error‘{0}’ does not implement interface member ‘{1}’
CS0537ErrorThe class System.Object cannot have a base class or implement an interface
CS0538Error‘{0}’ in explicit interface declaration is not an interface
CS0539Error‘{0}’ in explicit interface declaration is not found among members of the interface that can be implemented
CS0540Error‘{0}’: containing type does not implement interface ‘{1}’
CS0541Error‘{0}’: explicit interface declaration can only be declared in a class, record, struct or interface
CS0542Error‘{0}’: member names cannot be the same as their enclosing type
CS0543Error‘{0}’: the enumerator value is too large to fit in its type
CS0544Error‘{0}’: cannot override because ‘{1}’ is not a property
CS0545Error‘{0}’: cannot override because ‘{1}’ does not have an overridable get accessor
CS0546Error‘{0}’: cannot override because ‘{1}’ does not have an overridable set accessor
CS0547Error‘{0}’: property or indexer cannot have void type
CS0548Error‘{0}’: property or indexer must have at least one accessor
CS0549Error‘{0}’ is a new virtual member in sealed type ‘{1}’
CS0550Error‘{0}’ adds an accessor not found in interface member ‘{1}’
CS0551ErrorExplicit interface implementation ‘{0}’ is missing accessor ‘{1}’
CS0552Error‘{0}’: user-defined conversions to or from an interface are not allowed
CS0553Error‘{0}’: user-defined conversions to or from a base type are not allowed
CS0554Error‘{0}’: user-defined conversions to or from a derived type are not allowed
CS0555ErrorUser-defined operator cannot convert a type to itself
CS0556ErrorUser-defined conversion must convert to or from the enclosing type
CS0557ErrorDuplicate user-defined conversion in type ‘{0}’
CS0558ErrorUser-defined operator ‘{0}’ must be declared static and public
CS0559ErrorThe parameter type for ++ or — operator must be the containing type
CS0562ErrorThe parameter of a unary operator must be the containing type
CS0563ErrorOne of the parameters of a binary operator must be the containing type
CS0564ErrorThe first operand of an overloaded shift operator must have the same type as the containing type
CS0567ErrorConversion, equality, or inequality operators declared in interfaces must be abstract or virtual
CS0569Error‘{0}’: cannot override ‘{1}’ because it is not supported by the language
CS0570Error‘{0}’ is not supported by the language
CS0571Error‘{0}’: cannot explicitly call operator or accessor
CS0572Error‘{0}’: cannot reference a type through an expression; try ‘{1}’ instead
CS0574ErrorName of destructor must match name of type
CS0575ErrorOnly class types can contain destructors
CS0576ErrorNamespace ‘{1}’ contains a definition conflicting with alias ‘{0}’
CS0577ErrorThe Conditional attribute is not valid on ‘{0}’ because it is a constructor, destructor, operator, lambda expression, or explicit interface implementation
CS0578ErrorThe Conditional attribute is not valid on ‘{0}’ because its return type is not void
CS0579ErrorDuplicate ‘{0}’ attribute
CS0582ErrorThe Conditional attribute is not valid on interface members
CS0590ErrorUser-defined operators cannot return void
CS0591ErrorInvalid value for argument to ‘{0}’ attribute
CS0592ErrorAttribute ‘{0}’ is not valid on this declaration type. It is only valid on ‘{1}’ declarations.
CS0594ErrorFloating-point constant is outside the range of type ‘{0}’
CS0595ErrorInvalid real literal.
CS0596ErrorThe Guid attribute must be specified with the ComImport attribute
CS0599ErrorInvalid value for named attribute argument ‘{0}’
CS0601ErrorThe DllImport attribute must be specified on a method marked ‘static’ and ‘extern’
CS0610ErrorField or property cannot be of type ‘{0}’
CS0611ErrorArray elements cannot be of type ‘{0}’
CS0612Warning‘{0}’ is obsolete
CS0616Error‘{0}’ is not an attribute class
CS0617Error‘{0}’ is not a valid named attribute argument. Named attribute arguments must be fields which are not readonly, static, or const, or read-write properties which are public and not static.
CS0618Warning‘{0}’ is obsolete: ‘{1}’
CS0619Error‘{0}’ is obsolete: ‘{1}’
CS0620ErrorIndexers cannot have void type
CS0621Error‘{0}’: virtual or abstract members cannot be private
CS0622ErrorCan only use array initializer expressions to assign to array types. Try using a new expression instead.
CS0623ErrorArray initializers can only be used in a variable or field initializer. Try using a new expression instead.
CS0625Error‘{0}’: instance field in types marked with StructLayout(LayoutKind.Explicit) must have a FieldOffset attribute
CS0626WarningMethod, operator, or accessor ‘{0}’ is marked external and has no attributes on it. Consider adding a DllImport attribute to specify the external implementation.
CS0628Warning‘{0}’: new protected member declared in sealed type
CS0629ErrorConditional member ‘{0}’ cannot implement interface member ‘{1}’ in type ‘{2}’
CS0630Error‘{0}’ cannot implement interface member ‘{1}’ in type ‘{2}’ because it has an __arglist parameter
CS0631Errorref and out are not valid in this context
CS0633ErrorThe argument to the ‘{0}’ attribute must be a valid identifier
CS0636ErrorThe FieldOffset attribute can only be placed on members of types marked with the StructLayout(LayoutKind.Explicit)
CS0637ErrorThe FieldOffset attribute is not allowed on static or const fields
CS0641ErrorAttribute ‘{0}’ is only valid on classes derived from System.Attribute
CS0642WarningPossible mistaken empty statement
CS0643Error‘{0}’ duplicate named attribute argument
CS0644Error‘{0}’ cannot derive from special class ‘{1}’
CS0646ErrorCannot specify the DefaultMember attribute on a type containing an indexer
CS0648Error‘{0}’ is a type not supported by the language
CS0649WarningField ‘{0}’ is never assigned to, and will always have its default value {1}
CS0650ErrorBad array declarator: To declare a managed array the rank specifier precedes the variable’s identifier. To declare a fixed size buffer field, use the fixed keyword before the field type.
CS0652WarningComparison to integral constant is useless; the constant is outside the range of type ‘{0}’
CS0653ErrorCannot apply attribute class ‘{0}’ because it is abstract
CS0655Error‘{0}’ is not a valid named attribute argument because it is not a valid attribute parameter type
CS0656ErrorMissing compiler required member ‘{0}.{1}’
CS0657Warning‘{0}’ is not a valid attribute location for this declaration. Valid attribute locations for this declaration are ‘{1}’. All attributes in this block will be ignored.
CS0658Warning‘{0}’ is not a recognized attribute location. Valid attribute locations for this declaration are ‘{1}’. All attributes in this block will be ignored.
CS0659Warning‘{0}’ overrides Object.Equals(object o) but does not override Object.GetHashCode()
CS0660Warning‘{0}’ defines operator == or operator != but does not override Object.Equals(object o)
CS0661Warning‘{0}’ defines operator == or operator != but does not override Object.GetHashCode()
CS0662ErrorCannot specify the Out attribute on a ref parameter without also specifying the In attribute.
CS0663Error‘{0}’ cannot define an overloaded {1} that differs only on parameter modifiers ‘{2}’ and ‘{3}’
CS0664ErrorLiteral of type double cannot be implicitly converted to type ‘{1}’; use an ‘{0}’ suffix to create a literal of this type
CS0665WarningAssignment in conditional expression is always constant; did you mean to use == instead of = ?
CS0666Error‘{0}’: new protected member declared in struct
CS0668ErrorTwo indexers have different names; the IndexerName attribute must be used with the same name on every indexer within a type
CS0669ErrorA class with the ComImport attribute cannot have a user-defined constructor
CS0670ErrorField cannot have void type
CS0672WarningMember ‘{0}’ overrides obsolete member ‘{1}’. Add the Obsolete attribute to ‘{0}’.
CS0673ErrorSystem.Void cannot be used from C# — use typeof(void) to get the void type object
CS0674ErrorDo not use ‘System.ParamArrayAttribute’. Use the ‘params’ keyword instead.
CS0675WarningBitwise-or operator used on a sign-extended operand; consider casting to a smaller unsigned type first
CS0677Error‘{0}’: a volatile field cannot be of the type ‘{1}’
CS0678Error‘{0}’: a field cannot be both volatile and readonly
CS0681ErrorThe modifier ‘abstract’ is not valid on fields. Try using a property instead.
CS0682Error‘{0}’ cannot implement ‘{1}’ because it is not supported by the language
CS0683Error‘{0}’ explicit method implementation cannot implement ‘{1}’ because it is an accessor
CS0684Warning‘{0}’ interface marked with ‘CoClassAttribute’ not marked with ‘ComImportAttribute’
CS0685ErrorConditional member ‘{0}’ cannot have an out parameter
CS0686ErrorAccessor ‘{0}’ cannot implement interface member ‘{1}’ for type ‘{2}’. Use an explicit interface implementation.
CS0687ErrorThe namespace alias qualifier ‘::’ always resolves to a type or namespace so is illegal here. Consider using ‘.’ instead.
CS0689ErrorCannot derive from ‘{0}’ because it is a type parameter
CS0692ErrorDuplicate type parameter ‘{0}’
CS0693WarningType parameter ‘{0}’ has the same name as the type parameter from outer type ‘{1}’
CS0694ErrorType parameter ‘{0}’ has the same name as the containing type, or method
CS0695Error‘{0}’ cannot implement both ‘{1}’ and ‘{2}’ because they may unify for some type parameter substitutions
CS0699Error‘{1}’ does not define type parameter ‘{0}’
CS0701Error‘{0}’ is not a valid constraint. A type used as a constraint must be an interface, a non-sealed class or a type parameter.
CS0702ErrorConstraint cannot be special class ‘{0}’
CS0703ErrorInconsistent accessibility: constraint type ‘{1}’ is less accessible than ‘{0}’
CS0704ErrorCannot do non-virtual member lookup in ‘{0}’ because it is a type parameter
CS0706ErrorInvalid constraint type. A type used as a constraint must be an interface, a non-sealed class or a type parameter.
CS0708Error‘{0}’: cannot declare instance members in a static class
CS0709Error‘{1}’: cannot derive from static class ‘{0}’
CS0710ErrorStatic classes cannot have instance constructors
CS0711ErrorStatic classes cannot contain destructors
CS0712ErrorCannot create an instance of the static class ‘{0}’
CS0713ErrorStatic class ‘{0}’ cannot derive from type ‘{1}’. Static classes must derive from object.
CS0714Error‘{0}’: static classes cannot implement interfaces
CS0715Error‘{0}’: static classes cannot contain user-defined operators
CS0716ErrorCannot convert to static type ‘{0}’
CS0717Error‘{0}’: static classes cannot be used as constraints
CS0718Error‘{0}’: static types cannot be used as type arguments
CS0719Error‘{0}’: array elements cannot be of static type
CS0720Error‘{0}’: cannot declare indexers in a static class
CS0721Error‘{0}’: static types cannot be used as parameters
CS0722Error‘{0}’: static types cannot be used as return types
CS0723ErrorCannot declare a variable of static type ‘{0}’
CS0724ErrorA throw statement with no arguments is not allowed in a finally clause that is nested inside the nearest enclosing catch clause
CS0726Error‘{0}’ is not a valid format specifier
CS0728WarningPossibly incorrect assignment to local ‘{0}’ which is the argument to a using or lock statement. The Dispose call or unlocking will happen on the original value of the local.
CS0729ErrorType ‘{0}’ is defined in this assembly, but a type forwarder is specified for it
CS0730ErrorCannot forward type ‘{0}’ because it is a nested type of ‘{1}’
CS0731ErrorThe type forwarder for type ‘{0}’ in assembly ‘{1}’ causes a cycle
CS0734ErrorThe /moduleassemblyname option may only be specified when building a target type of ‘module’
CS0735ErrorInvalid type specified as an argument for TypeForwardedTo attribute
CS0736Error‘{0}’ does not implement instance interface member ‘{1}’. ‘{2}’ cannot implement the interface member because it is static.
CS0737Error‘{0}’ does not implement interface member ‘{1}’. ‘{2}’ cannot implement an interface member because it is not public.
CS0738Error‘{0}’ does not implement interface member ‘{1}’. ‘{2}’ cannot implement ‘{1}’ because it does not have the matching return type of ‘{3}’.
CS0739Error‘{0}’ duplicate TypeForwardedToAttribute
CS0742ErrorA query body must end with a select clause or a group clause
CS0743ErrorExpected contextual keyword ‘on’
CS0744ErrorExpected contextual keyword ‘equals’
CS0745ErrorExpected contextual keyword ‘by’
CS0746ErrorInvalid anonymous type member declarator. Anonymous type members must be declared with a member assignment, simple name or member access.
CS0747ErrorInvalid initializer member declarator
CS0748ErrorInconsistent lambda parameter usage; parameter types must be all explicit or all implicit
CS0750ErrorA partial method cannot have the ‘abstract’ modifier
CS0751ErrorA partial method must be declared within a partial type
CS0754ErrorA partial method may not explicitly implement an interface method
CS0755ErrorBoth partial method declarations must be extension methods or neither may be an extension method
CS0756ErrorA partial method may not have multiple defining declarations
CS0757ErrorA partial method may not have multiple implementing declarations
CS0758ErrorBoth partial method declarations must use a params parameter or neither may use a params parameter
CS0759ErrorNo defining declaration found for implementing declaration of partial method ‘{0}’
CS0761ErrorPartial method declarations of ‘{0}’ have inconsistent constraints for type parameter ‘{1}’
CS0762ErrorCannot create delegate from method ‘{0}’ because it is a partial method without an implementing declaration
CS0763ErrorBoth partial method declarations must be static or neither may be static
CS0764ErrorBoth partial method declarations must be unsafe or neither may be unsafe
CS0765ErrorPartial methods with only a defining declaration or removed conditional methods cannot be used in expression trees
CS0767ErrorCannot inherit interface ‘{0}’ with the specified type parameters because it causes method ‘{1}’ to contain overloads which differ only on ref and out
CS0768ErrorConstructor ‘{0}’ cannot call itself through another constructor
CS0809WarningObsolete member ‘{0}’ overrides non-obsolete member ‘{1}’
CS0811WarningThe fully qualified name for ‘{0}’ is too long for debug information. Compile without ‘/debug’ option.
CS0815ErrorCannot assign {0} to an implicitly-typed variable
CS0818ErrorImplicitly-typed variables must be initialized
CS0819ErrorImplicitly-typed variables cannot have multiple declarators
CS0820ErrorCannot initialize an implicitly-typed variable with an array initializer
CS0821ErrorImplicitly-typed local variables cannot be fixed
CS0822ErrorImplicitly-typed variables cannot be constant
CS0824WarningConstructor ‘{0}’ is marked external
CS0825ErrorThe contextual keyword ‘var’ may only appear within a local variable declaration or in script code
CS0826ErrorNo best type found for implicitly-typed array
CS0828ErrorCannot assign ‘{0}’ to anonymous type property
CS0831ErrorAn expression tree may not contain a base access
CS0832ErrorAn expression tree may not contain an assignment operator
CS0833ErrorAn anonymous type cannot have multiple properties with the same name
CS0834ErrorA lambda expression with a statement body cannot be converted to an expression tree
CS0835ErrorCannot convert lambda to an expression tree whose type argument ‘{0}’ is not a delegate type
CS0836ErrorCannot use anonymous type in a constant expression
CS0837ErrorThe first operand of an ‘is’ or ‘as’ operator may not be a lambda expression, anonymous method, or method group.
CS0838ErrorAn expression tree may not contain a multidimensional array initializer
CS0839ErrorArgument missing
CS0841ErrorCannot use local variable ‘{0}’ before it is declared
CS0843ErrorAuto-implemented property ‘{0}’ must be fully assigned before control is returned to the caller. Consider updating to language version ‘{1}’ to auto-default the property.
CS0844ErrorCannot use local variable ‘{0}’ before it is declared. The declaration of the local variable hides the field ‘{1}’.
CS0845ErrorAn expression tree lambda may not contain a coalescing operator with a null or default literal left-hand side
CS0846ErrorA nested array initializer is expected
CS0847ErrorAn array initializer of length ‘{0}’ is expected
CS0853ErrorAn expression tree may not contain a named argument specification
CS0854ErrorAn expression tree may not contain a call or invocation that uses optional arguments
CS0855ErrorAn expression tree may not contain an indexed property
CS0856ErrorIndexed property ‘{0}’ has non-optional arguments which must be provided
CS0857ErrorIndexed property ‘{0}’ must have all arguments optional

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