C# Compiler Error
CS0260 – Missing partial modifier on declaration of type ‘type’; another partial declaration of this type exists
Reason for the Error
You’ll get this error in your C# code when you have declared multiple classes with the same name and atleast one of the the class is declared as partial and some doesnot contain partial modifier.
For example, lets try to compile the below code snippet.
namespace DeveloperPubNamespace { class class1 { } partial class class1 { } class Program { public static void Main() { } } }
You’ll receive the error code CS0260 when you try to build the C# program because you have defined the class “class1” twice but the partial modifier is used only on one of the definition.
Error CS0260 Missing partial modifier on declaration of type ‘class1’; another partial declaration of this type exists DeveloperPublish C:\Users\Senthil\source\repos\ConsoleApp3\ConsoleApp3\Program.cs 3 Active
Solution
In C#, if you want to define a class in several parts, you must declare each part of the class using the partial modifier. You can fix the error in the above program by ensuring that both the parts of the “class1” is defined with the partial modifier as shown below.
namespace DeveloperPubNamespace { partial class class1 { } partial class class1 { } class Program { public static void Main() { } } }