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 Code | Type | Error/Warning Description |
---|---|---|
CS0501 | Error | ‘{0}’ must declare a body because it is not marked abstract, extern, or partial |
CS0502 | Error | ‘{0}’ cannot be both abstract and sealed |
CS0503 | Error | The abstract {0} ‘{1}’ cannot be marked virtual |
CS0504 | Error | The constant ‘{0}’ cannot be marked static |
CS0505 | Error | ‘{0}’: cannot override because ‘{1}’ is not a function |
CS0506 | Error | ‘{0}’: cannot override inherited member ‘{1}’ because it is not marked virtual, abstract, or override |
CS0507 | Error | ‘{0}’: cannot change access modifiers when overriding ‘{1}’ inherited member ‘{2}’ |
CS0508 | Error | ‘{0}’: return type must be ‘{2}’ to match overridden member ‘{1}’ |
CS0509 | Error | ‘{0}’: cannot derive from sealed type ‘{1}’ |
CS0513 | Error | ‘{0}’ is abstract but it is contained in non-abstract type ‘{1}’ |
CS0514 | Error | ‘{0}’: static constructor cannot have an explicit ‘this’ or ‘base’ constructor call |
CS0515 | Error | ‘{0}’: access modifiers are not allowed on static constructors |
CS0516 | Error | Constructor ‘{0}’ cannot call itself |
CS0517 | Error | ‘{0}’ has no base class and cannot call a base constructor |
CS0518 | Error | Predefined type ‘{0}’ is not defined or imported |
CS0522 | Error | ‘{0}’: structs cannot call base class constructors |
CS0523 | Error | Struct member ‘{0}’ of type ‘{1}’ causes a cycle in the struct layout |
CS0525 | Error | Interfaces cannot contain instance fields |
CS0526 | Error | Interfaces cannot contain instance constructors |
CS0527 | Error | Type ‘{0}’ in interface list is not an interface |
CS0528 | Error | ‘{0}’ is already listed in interface list |
CS0529 | Error | Inherited interface ‘{1}’ causes a cycle in the interface hierarchy of ‘{0}’ |
CS0533 | Error | ‘{0}’ hides inherited abstract member ‘{1}’ |
CS0534 | Error | ‘{0}’ does not implement inherited abstract member ‘{1}’ |
CS0535 | Error | ‘{0}’ does not implement interface member ‘{1}’ |
CS0537 | Error | The class System.Object cannot have a base class or implement an interface |
CS0538 | Error | ‘{0}’ in explicit interface declaration is not an interface |
CS0539 | Error | ‘{0}’ in explicit interface declaration is not found among members of the interface that can be implemented |
CS0540 | Error | ‘{0}’: containing type does not implement interface ‘{1}’ |
CS0541 | Error | ‘{0}’: explicit interface declaration can only be declared in a class, record, struct or interface |
CS0542 | Error | ‘{0}’: member names cannot be the same as their enclosing type |
CS0543 | Error | ‘{0}’: the enumerator value is too large to fit in its type |
CS0544 | Error | ‘{0}’: cannot override because ‘{1}’ is not a property |
CS0545 | Error | ‘{0}’: cannot override because ‘{1}’ does not have an overridable get accessor |
CS0546 | Error | ‘{0}’: cannot override because ‘{1}’ does not have an overridable set accessor |
CS0547 | Error | ‘{0}’: property or indexer cannot have void type |
CS0548 | Error | ‘{0}’: property or indexer must have at least one accessor |
CS0549 | Error | ‘{0}’ is a new virtual member in sealed type ‘{1}’ |
CS0550 | Error | ‘{0}’ adds an accessor not found in interface member ‘{1}’ |
CS0551 | Error | Explicit interface implementation ‘{0}’ is missing accessor ‘{1}’ |
CS0552 | Error | ‘{0}’: user-defined conversions to or from an interface are not allowed |
CS0553 | Error | ‘{0}’: user-defined conversions to or from a base type are not allowed |
CS0554 | Error | ‘{0}’: user-defined conversions to or from a derived type are not allowed |
CS0555 | Error | User-defined operator cannot convert a type to itself |
CS0556 | Error | User-defined conversion must convert to or from the enclosing type |
CS0557 | Error | Duplicate user-defined conversion in type ‘{0}’ |
CS0558 | Error | User-defined operator ‘{0}’ must be declared static and public |
CS0559 | Error | The parameter type for ++ or — operator must be the containing type |
CS0562 | Error | The parameter of a unary operator must be the containing type |
CS0563 | Error | One of the parameters of a binary operator must be the containing type |
CS0564 | Error | The first operand of an overloaded shift operator must have the same type as the containing type |
CS0567 | Error | Conversion, equality, or inequality operators declared in interfaces must be abstract or virtual |
CS0569 | Error | ‘{0}’: cannot override ‘{1}’ because it is not supported by the language |
CS0570 | Error | ‘{0}’ is not supported by the language |
CS0571 | Error | ‘{0}’: cannot explicitly call operator or accessor |
CS0572 | Error | ‘{0}’: cannot reference a type through an expression; try ‘{1}’ instead |
CS0574 | Error | Name of destructor must match name of type |
CS0575 | Error | Only class types can contain destructors |
CS0576 | Error | Namespace ‘{1}’ contains a definition conflicting with alias ‘{0}’ |
CS0577 | Error | The Conditional attribute is not valid on ‘{0}’ because it is a constructor, destructor, operator, lambda expression, or explicit interface implementation |
CS0578 | Error | The Conditional attribute is not valid on ‘{0}’ because its return type is not void |
CS0579 | Error | Duplicate ‘{0}’ attribute |
CS0582 | Error | The Conditional attribute is not valid on interface members |
CS0590 | Error | User-defined operators cannot return void |
CS0591 | Error | Invalid value for argument to ‘{0}’ attribute |
CS0592 | Error | Attribute ‘{0}’ is not valid on this declaration type. It is only valid on ‘{1}’ declarations. |
CS0594 | Error | Floating-point constant is outside the range of type ‘{0}’ |
CS0595 | Error | Invalid real literal. |
CS0596 | Error | The Guid attribute must be specified with the ComImport attribute |
CS0599 | Error | Invalid value for named attribute argument ‘{0}’ |
CS0601 | Error | The DllImport attribute must be specified on a method marked ‘static’ and ‘extern’ |
CS0610 | Error | Field or property cannot be of type ‘{0}’ |
CS0611 | Error | Array elements cannot be of type ‘{0}’ |
CS0612 | Warning | ‘{0}’ is obsolete |
CS0616 | Error | ‘{0}’ is not an attribute class |
CS0617 | Error | ‘{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. |
CS0618 | Warning | ‘{0}’ is obsolete: ‘{1}’ |
CS0619 | Error | ‘{0}’ is obsolete: ‘{1}’ |
CS0620 | Error | Indexers cannot have void type |
CS0621 | Error | ‘{0}’: virtual or abstract members cannot be private |
CS0622 | Error | Can only use array initializer expressions to assign to array types. Try using a new expression instead. |
CS0623 | Error | Array initializers can only be used in a variable or field initializer. Try using a new expression instead. |
CS0625 | Error | ‘{0}’: instance field in types marked with StructLayout(LayoutKind.Explicit) must have a FieldOffset attribute |
CS0626 | Warning | Method, operator, or accessor ‘{0}’ is marked external and has no attributes on it. Consider adding a DllImport attribute to specify the external implementation. |
CS0628 | Warning | ‘{0}’: new protected member declared in sealed type |
CS0629 | Error | Conditional member ‘{0}’ cannot implement interface member ‘{1}’ in type ‘{2}’ |
CS0630 | Error | ‘{0}’ cannot implement interface member ‘{1}’ in type ‘{2}’ because it has an __arglist parameter |
CS0631 | Error | ref and out are not valid in this context |
CS0633 | Error | The argument to the ‘{0}’ attribute must be a valid identifier |
CS0636 | Error | The FieldOffset attribute can only be placed on members of types marked with the StructLayout(LayoutKind.Explicit) |
CS0637 | Error | The FieldOffset attribute is not allowed on static or const fields |
CS0641 | Error | Attribute ‘{0}’ is only valid on classes derived from System.Attribute |
CS0642 | Warning | Possible mistaken empty statement |
CS0643 | Error | ‘{0}’ duplicate named attribute argument |
CS0644 | Error | ‘{0}’ cannot derive from special class ‘{1}’ |
CS0646 | Error | Cannot specify the DefaultMember attribute on a type containing an indexer |
CS0648 | Error | ‘{0}’ is a type not supported by the language |
CS0649 | Warning | Field ‘{0}’ is never assigned to, and will always have its default value {1} |
CS0650 | Error | Bad 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. |
CS0652 | Warning | Comparison to integral constant is useless; the constant is outside the range of type ‘{0}’ |
CS0653 | Error | Cannot apply attribute class ‘{0}’ because it is abstract |
CS0655 | Error | ‘{0}’ is not a valid named attribute argument because it is not a valid attribute parameter type |
CS0656 | Error | Missing compiler required member ‘{0}.{1}’ |
CS0657 | Warning | ‘{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. |
CS0658 | Warning | ‘{0}’ is not a recognized attribute location. Valid attribute locations for this declaration are ‘{1}’. All attributes in this block will be ignored. |
CS0659 | Warning | ‘{0}’ overrides Object.Equals(object o) but does not override Object.GetHashCode() |
CS0660 | Warning | ‘{0}’ defines operator == or operator != but does not override Object.Equals(object o) |
CS0661 | Warning | ‘{0}’ defines operator == or operator != but does not override Object.GetHashCode() |
CS0662 | Error | Cannot specify the Out attribute on a ref parameter without also specifying the In attribute. |
CS0663 | Error | ‘{0}’ cannot define an overloaded {1} that differs only on parameter modifiers ‘{2}’ and ‘{3}’ |
CS0664 | Error | Literal of type double cannot be implicitly converted to type ‘{1}’; use an ‘{0}’ suffix to create a literal of this type |
CS0665 | Warning | Assignment in conditional expression is always constant; did you mean to use == instead of = ? |
CS0666 | Error | ‘{0}’: new protected member declared in struct |
CS0668 | Error | Two indexers have different names; the IndexerName attribute must be used with the same name on every indexer within a type |
CS0669 | Error | A class with the ComImport attribute cannot have a user-defined constructor |
CS0670 | Error | Field cannot have void type |
CS0672 | Warning | Member ‘{0}’ overrides obsolete member ‘{1}’. Add the Obsolete attribute to ‘{0}’. |
CS0673 | Error | System.Void cannot be used from C# — use typeof(void) to get the void type object |
CS0674 | Error | Do not use ‘System.ParamArrayAttribute’. Use the ‘params’ keyword instead. |
CS0675 | Warning | Bitwise-or operator used on a sign-extended operand; consider casting to a smaller unsigned type first |
CS0677 | Error | ‘{0}’: a volatile field cannot be of the type ‘{1}’ |
CS0678 | Error | ‘{0}’: a field cannot be both volatile and readonly |
CS0681 | Error | The modifier ‘abstract’ is not valid on fields. Try using a property instead. |
CS0682 | Error | ‘{0}’ cannot implement ‘{1}’ because it is not supported by the language |
CS0683 | Error | ‘{0}’ explicit method implementation cannot implement ‘{1}’ because it is an accessor |
CS0684 | Warning | ‘{0}’ interface marked with ‘CoClassAttribute’ not marked with ‘ComImportAttribute’ |
CS0685 | Error | Conditional member ‘{0}’ cannot have an out parameter |
CS0686 | Error | Accessor ‘{0}’ cannot implement interface member ‘{1}’ for type ‘{2}’. Use an explicit interface implementation. |
CS0687 | Error | The namespace alias qualifier ‘::’ always resolves to a type or namespace so is illegal here. Consider using ‘.’ instead. |
CS0689 | Error | Cannot derive from ‘{0}’ because it is a type parameter |
CS0692 | Error | Duplicate type parameter ‘{0}’ |
CS0693 | Warning | Type parameter ‘{0}’ has the same name as the type parameter from outer type ‘{1}’ |
CS0694 | Error | Type parameter ‘{0}’ has the same name as the containing type, or method |
CS0695 | Error | ‘{0}’ cannot implement both ‘{1}’ and ‘{2}’ because they may unify for some type parameter substitutions |
CS0699 | Error | ‘{1}’ does not define type parameter ‘{0}’ |
CS0701 | Error | ‘{0}’ is not a valid constraint. A type used as a constraint must be an interface, a non-sealed class or a type parameter. |
CS0702 | Error | Constraint cannot be special class ‘{0}’ |
CS0703 | Error | Inconsistent accessibility: constraint type ‘{1}’ is less accessible than ‘{0}’ |
CS0704 | Error | Cannot do non-virtual member lookup in ‘{0}’ because it is a type parameter |
CS0706 | Error | Invalid constraint type. A type used as a constraint must be an interface, a non-sealed class or a type parameter. |
CS0708 | Error | ‘{0}’: cannot declare instance members in a static class |
CS0709 | Error | ‘{1}’: cannot derive from static class ‘{0}’ |
CS0710 | Error | Static classes cannot have instance constructors |
CS0711 | Error | Static classes cannot contain destructors |
CS0712 | Error | Cannot create an instance of the static class ‘{0}’ |
CS0713 | Error | Static class ‘{0}’ cannot derive from type ‘{1}’. Static classes must derive from object. |
CS0714 | Error | ‘{0}’: static classes cannot implement interfaces |
CS0715 | Error | ‘{0}’: static classes cannot contain user-defined operators |
CS0716 | Error | Cannot convert to static type ‘{0}’ |
CS0717 | Error | ‘{0}’: static classes cannot be used as constraints |
CS0718 | Error | ‘{0}’: static types cannot be used as type arguments |
CS0719 | Error | ‘{0}’: array elements cannot be of static type |
CS0720 | Error | ‘{0}’: cannot declare indexers in a static class |
CS0721 | Error | ‘{0}’: static types cannot be used as parameters |
CS0722 | Error | ‘{0}’: static types cannot be used as return types |
CS0723 | Error | Cannot declare a variable of static type ‘{0}’ |
CS0724 | Error | A throw statement with no arguments is not allowed in a finally clause that is nested inside the nearest enclosing catch clause |
CS0726 | Error | ‘{0}’ is not a valid format specifier |
CS0728 | Warning | Possibly 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. |
CS0729 | Error | Type ‘{0}’ is defined in this assembly, but a type forwarder is specified for it |
CS0730 | Error | Cannot forward type ‘{0}’ because it is a nested type of ‘{1}’ |
CS0731 | Error | The type forwarder for type ‘{0}’ in assembly ‘{1}’ causes a cycle |
CS0734 | Error | The /moduleassemblyname option may only be specified when building a target type of ‘module’ |
CS0735 | Error | Invalid type specified as an argument for TypeForwardedTo attribute |
CS0736 | Error | ‘{0}’ does not implement instance interface member ‘{1}’. ‘{2}’ cannot implement the interface member because it is static. |
CS0737 | Error | ‘{0}’ does not implement interface member ‘{1}’. ‘{2}’ cannot implement an interface member because it is not public. |
CS0738 | Error | ‘{0}’ does not implement interface member ‘{1}’. ‘{2}’ cannot implement ‘{1}’ because it does not have the matching return type of ‘{3}’. |
CS0739 | Error | ‘{0}’ duplicate TypeForwardedToAttribute |
CS0742 | Error | A query body must end with a select clause or a group clause |
CS0743 | Error | Expected contextual keyword ‘on’ |
CS0744 | Error | Expected contextual keyword ‘equals’ |
CS0745 | Error | Expected contextual keyword ‘by’ |
CS0746 | Error | Invalid anonymous type member declarator. Anonymous type members must be declared with a member assignment, simple name or member access. |
CS0747 | Error | Invalid initializer member declarator |
CS0748 | Error | Inconsistent lambda parameter usage; parameter types must be all explicit or all implicit |
CS0750 | Error | A partial method cannot have the ‘abstract’ modifier |
CS0751 | Error | A partial method must be declared within a partial type |
CS0754 | Error | A partial method may not explicitly implement an interface method |
CS0755 | Error | Both partial method declarations must be extension methods or neither may be an extension method |
CS0756 | Error | A partial method may not have multiple defining declarations |
CS0757 | Error | A partial method may not have multiple implementing declarations |
CS0758 | Error | Both partial method declarations must use a params parameter or neither may use a params parameter |
CS0759 | Error | No defining declaration found for implementing declaration of partial method ‘{0}’ |
CS0761 | Error | Partial method declarations of ‘{0}’ have inconsistent constraints for type parameter ‘{1}’ |
CS0762 | Error | Cannot create delegate from method ‘{0}’ because it is a partial method without an implementing declaration |
CS0763 | Error | Both partial method declarations must be static or neither may be static |
CS0764 | Error | Both partial method declarations must be unsafe or neither may be unsafe |
CS0765 | Error | Partial methods with only a defining declaration or removed conditional methods cannot be used in expression trees |
CS0767 | Error | Cannot inherit interface ‘{0}’ with the specified type parameters because it causes method ‘{1}’ to contain overloads which differ only on ref and out |
CS0768 | Error | Constructor ‘{0}’ cannot call itself through another constructor |
CS0809 | Warning | Obsolete member ‘{0}’ overrides non-obsolete member ‘{1}’ |
CS0811 | Warning | The fully qualified name for ‘{0}’ is too long for debug information. Compile without ‘/debug’ option. |
CS0815 | Error | Cannot assign {0} to an implicitly-typed variable |
CS0818 | Error | Implicitly-typed variables must be initialized |
CS0819 | Error | Implicitly-typed variables cannot have multiple declarators |
CS0820 | Error | Cannot initialize an implicitly-typed variable with an array initializer |
CS0821 | Error | Implicitly-typed local variables cannot be fixed |
CS0822 | Error | Implicitly-typed variables cannot be constant |
CS0824 | Warning | Constructor ‘{0}’ is marked external |
CS0825 | Error | The contextual keyword ‘var’ may only appear within a local variable declaration or in script code |
CS0826 | Error | No best type found for implicitly-typed array |
CS0828 | Error | Cannot assign ‘{0}’ to anonymous type property |
CS0831 | Error | An expression tree may not contain a base access |
CS0832 | Error | An expression tree may not contain an assignment operator |
CS0833 | Error | An anonymous type cannot have multiple properties with the same name |
CS0834 | Error | A lambda expression with a statement body cannot be converted to an expression tree |
CS0835 | Error | Cannot convert lambda to an expression tree whose type argument ‘{0}’ is not a delegate type |
CS0836 | Error | Cannot use anonymous type in a constant expression |
CS0837 | Error | The first operand of an ‘is’ or ‘as’ operator may not be a lambda expression, anonymous method, or method group. |
CS0838 | Error | An expression tree may not contain a multidimensional array initializer |
CS0839 | Error | Argument missing |
CS0841 | Error | Cannot use local variable ‘{0}’ before it is declared |
CS0843 | Error | Auto-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. |
CS0844 | Error | Cannot use local variable ‘{0}’ before it is declared. The declaration of the local variable hides the field ‘{1}’. |
CS0845 | Error | An expression tree lambda may not contain a coalescing operator with a null or default literal left-hand side |
CS0846 | Error | A nested array initializer is expected |
CS0847 | Error | An array initializer of length ‘{0}’ is expected |
CS0853 | Error | An expression tree may not contain a named argument specification |
CS0854 | Error | An expression tree may not contain a call or invocation that uses optional arguments |
CS0855 | Error | An expression tree may not contain an indexed property |
CS0856 | Error | Indexed property ‘{0}’ has non-optional arguments which must be provided |
CS0857 | Error | Indexed property ‘{0}’ must have all arguments optional |