Advertisement

04.06.2008 at 06:38AM PDT, ID: 23299430
[x]
Attachment Details

How to Fix Overload resolution failed  Error

Asked by AXSYSTEC in Microsoft Visual Basic.Net, Visual Studio, .NET Framework 2.x

Tags: , , ,

I have a vb.net function that expects 2 parameters - example :  
GetCustomer(byval Addr1 as string, byval Addr2 as string).
The calling program calls this function by passing 2 string variables,example:
myCustomer = GetCustomer(strAddr1, strAddr2)

The function works well when both strAddr1 and strAddr2 have string values. However, sometimes strAddr2 is NULL.  In that case, when the function is called, I get an error: Overload resolution failed because no Public 'GetCustomer' is most specific for these arguments..

One way I know how to fix this problem is  to create an Overloaded copy of GetCustomer function with only strAddr1 as prameter. Likethis the index is different. In this case the calling program will first check if strAddr2 is null, and call appropriate version of GetCustomer.

However, I want to be able to use only single version of GetCustomer without creating overloaded copy because there is too much of code init to duplicate. Therefore is there a way to keep the GetCustomer function with 2 parameters,  and calling program still able to pass a null vaue to one of its prameters ?  Can I define type of parameters in Getcustomer function to something other than string, like say unknown type ?  
These are just examples from a more complex requirement,  but the parameters being passed may be nulls, string or integers and one function needs to handle them all without creating multiple overloaded copies.

Thanks.






Start Free Trial
 
Loading Advertisement...
 
[+][-]04.06.2008 at 07:04AM PDT, ID: 21291779

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.06.2008 at 07:35AM PDT, ID: 21291870

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.06.2008 at 07:42AM PDT, ID: 21291900

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.06.2008 at 07:50AM PDT, ID: 21291920

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.06.2008 at 07:57AM PDT, ID: 21291946

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.06.2008 at 07:58AM PDT, ID: 21291949

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.06.2008 at 08:14AM PDT, ID: 21292056

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.06.2008 at 08:35AM PDT, ID: 21292105

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.06.2008 at 09:55AM PDT, ID: 21292374

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.06.2008 at 11:33AM PDT, ID: 21292677

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.06.2008 at 03:58PM PDT, ID: 21293483

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Microsoft Visual Basic.Net, Visual Studio, .NET Framework 2.x
Tags: Microsoft, VB.NET, Dot Net Framework 2.0, Null Value Received by Function expecting String parameter
Sign Up Now!
Solution Provided By: Sancler
Participating Experts: 3
Solution Grade: A
 
 
[+][-]06.07.2008 at 07:13AM PDT, ID: 21735555

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628