Compiler Error CS0121 The call is ambiguous between the following methods or properties: 'TestMethod' and 'TestMethod'
The compiler was not able to call one form of an overloaded method. In other word Compiler can not decide which overload method should use.
C# Code
public class Parent { public void TestMethod() { Console.WriteLine("Message from Parent.TestMethod()."); } public string TestMethod() { Console.WriteLine("Message from Parent.TestMethod() return type string."); return string.Empty; } }
Solution
You can resolve above error in the following ways:
- Specify the method parameters in such a way that implicit conversion does not take place.
- Remove all overloads for the method.
- Cast to proper type before calling method.
No comments:
Post a Comment