您的位置:首页 > 大数据 > 人工智能

Overload resolution failed because no Public 'Add' is most specific for these arguments

2007-08-01 08:20 786 查看
ex.Message = "Overload resolution failed because no Public 'Add' is most specific for these arguments:
'Public Sub Add(item As System.Web.UI.WebControls.ListItem)':
Not most specific.
'Public Sub Add(item As String)':
Not most specific."

what do you meaning?
why?

Microsoft MSDN Description

Visual Basic Reference: Error Messages
Overload resolution failed because no accessible '<method>' is most specific for these arguments:<error>

You
have made a call to an overloaded method, but the compiler has found
two or more overloads with parameter lists to which your argument list
can be converted, and it cannot select among them.

The compiler
attempts to match the data types in the calling argument list and the
overload parameter list as closely as possible. It requires a widening
conversion from every one of your arguments to its corresponding
parameter, whether the type checking switch (Option Strict Statement) is On or Off.

If
the compiler finds more than one overload satisfying the widening
requirement, it then looks for the overload that is most specific for
the argument data types, that is, that calls for the least amount of
widening. It generates this error message when one overload is more
specific for one argument's data type while another overload is more
specific for another argument's data type. For more information and an
example, see Overload Resolution.

Error ID: BC30521

To correct this error

Review all the overloads for the method and determine which one you want to call.

In
your calling statement, make the data types of the arguments match the
data types of the parameters defined for the desired overload. You
might have to use the CType Function to convert one or more data types to the defined types.

See Also

Reference

Overloads
Option Strict Statement
CType Function

Concepts

Procedure Overloading
Considerations in Overloading Procedures
Overload Resolution
Overloaded Properties and Methods
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐