C# Compiler Error
CS0101 – The namespace ‘namespace’ already contains a definition for ‘type’
Reason for the Error
You will receive this error when your namespace has duplicate identifiers that is declared.
For example, the below code snippet contains the namespace DeveloperPublish but contains two classes with the same name “Class1”.
namespace DeveloperPublish { class Class1 { } class Class1 { } public class Program { public static void Main() { } } }
This will result with the error.
Error CS0101 The namespace ‘DeveloperPublish’ already contains a definition for ‘Class1’ ConsoleApp2 C:\Users\admin\source\repos\ConsoleApp2\ConsoleApp2\Program.cs 8 Active
Solution
To fix the error, rename or delete one of the duplicate identifiers. If it is a class, try moving it to a different namespace.