functions

  • Thread starter Thread starter Gav
  • Start date Start date
G

Gav

Can you overload functions in .NET?

I using C# I used to use C++ and in this I could declare a function as:

func1()
{
}

and I could also declare a function as:

func1(string sParam1)
{

}

then depending on whether or not I call:

func(); or
func(somestring);

it would call one or the other. Can I not do this anymore in C#.NET?

Thanks
Gavin
 
Hello Gav,

Function overloading in C# works the same as C++, go ahead :)

Maher
(e-mail address removed)
 
How can I do this with web services methods? Its complaining about
MessageName custom attribute to specify unique names.

Thanks for the help
Gav
 
Hello Gav,

Thanks for your post. In web services methods, you can use the MessageName
property to uniquely identify polymorphic methods. Please refer to the
following sample and MSDN documentation:

//-------------------code snippet------------------------
public class Calculator : WebService {
// The MessageName property defaults to Add for this XML Web service
method.
[WebMethod]
public int Add(int i, int j) {
return i + j;
}
[WebMethod(MessageName="Add2")]
public int Add(int i, int j, int k) {
return i + j + k;
}
}
//-----------------------end of-------------------------

WebMethodAttribute.MessageName Property
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
frlrfSystemWebServicesWebMethodAttributeClassMessageNameTopic.asp

Please feel free to let me know if you have any problems or concerns.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Hello Gav,

I wanted to post a quick note to see if you would like additional
assistance or information regarding this particular issue. We appreciate
your patience and look forward to hearing from you!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Back
Top