Why is .NET telling me my function is ambiguous?
I am working on a website in .NET 4, and it is giving me the following error:
'Trim' is ambiguous, imported from the namespaces or types 'MyLib.WEB.TextboxEx, Microsoft.VisualBasic.Strings'.
Problem is, which is confusing me, is that these functions have completely different signatures, so I have no idea why they would conflict.
The System function is defined as:
Public Function Trim(str As String) As String
While the MyLib one is defined as:
<Extension> Public Function Trim(
target As System.Web.UI.WebControls.TextBox
) As System.Web.UI.WebControls.TextBox
Given that t开发者_Python百科hey have wholly different signatures apart from the name, how can they possibly be ambiguous?
Because overloading only works within the same class, it cannot tell if you're passing the wrong parameters to the method you meant to call. Best to tweak the using statements or fully qualify your call.
精彩评论