How to Resolve Error "CS0082: Type 'type' already reserves a member called 'name' with the same parameter types" in C#
The Compiler Error CS0082 is an Overloading Ambiguity error. The message reads: "Type 'MyClass' already reserves a member called 'MethodName' with the same parameter types".
In C#, you are allowed to have multiple methods with the same name (Method Overloading), provided they have different Parameter Lists (different types, or a different number of parameters). However, the Return Type is not part of the method signature used for uniqueness.
If you define two methods with the exact same name and parameters, but different return types, the compiler cannot distinguish between them, resulting in CS0082.
Understanding Method Signatures
When the compiler looks at a method to see if it is unique, it checks:
- The Name: (e.g.,
Calculate) - The Parameter Types: (e.g.,
int,string) - The Parameter Modifiers: (e.g.,
ref,out)
Crucially, it ignores the return type.
void DoWork(int a)is the same asstring DoWork(int a).void DoWork(int a)is different fromvoid DoWork(string s).
Scenario 1: Overloading by Return Type (The Common Mistake)
This is the most frequent cause. You want a method to return an integer in one case and a string in another, taking the same input.
Example of Error
public class DataConverter
{
// First definition
public int GetValue(string input)
{
return int.Parse(input);
}
// ⛔️ Error CS0082: Type 'DataConverter' already reserves a member called 'GetValue'
// with the same parameter types.
// The compiler ignores 'string' vs 'int' return type. It only sees 'GetValue(string)'.
public string GetValue(string input)
{
return input;
}
}
Solution: Rename or Change Parameters
You must change the method name or the input parameters.
public class DataConverter
{
// ✅ Correct: Renaming makes them unique
public int GetIntValue(string input)
{
return int.Parse(input);
}
public string GetStringValue(string input)
{
return input;
}
}
Scenario 2: Properties vs. Methods
In C#, Properties are internally compiled into methods (e.g., get_Name and set_Name). While rare, it is possible to have a naming collision if you try to define a method that conflicts with these reserved internal names, or simply have a Property and a Method with the exact same name (which is generally forbidden by CS0102, but can manifest as CS0082 in specific IL generation scenarios).
More commonly, this error appears if you try to create a constructor that looks exactly like a method due to a typo.
Example of Error
public class User
{
public User() { }
// ⛔️ Error CS0082: This looks like a constructor redefinition
// or a method collision depending on context.
public void User() { }
}
Solution
Ensure constructors do not have return types (even void), and ensure standard methods do not share names with the class (which makes them look like constructors).
Scenario 3: Partial Classes
If you use Partial Classes (splitting one class across multiple files, common in WinForms or ASP.NET), you might accidentally define the exact same method in both files.
File 1 (User.cs):
public partial class User
{
public void Save() { /* ... */ }
}
File 2 (User.Generated.cs):
public partial class User
{
// ⛔️ Error CS0082: 'Save' is already defined in the other file.
public void Save() { /* ... */ }
}
Solution
Check your other files. If the method is intended to be implemented in one file and declared in another, use partial methods. Otherwise, delete the duplicate.
// File 1
public partial class User
{
// Definition
partial void OnSaved();
public void Save()
{
OnSaved();
}
}
// File 2
public partial class User
{
// Implementation
partial void OnSaved()
{
System.Console.WriteLine("Saved!");
}
}
Conclusion
CS0082 ensures ambiguity does not exist in your class members.
- Check Return Types: Remember that changing only the return type (
voidvsint) does not create a valid overload. - Rename Methods: Use descriptive names like
GetInt()andGetString()instead of relying on overloads. - Check Partials: Ensure you haven't copy-pasted the same method into two different files belonging to the same class.