473,382 Members | 1,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

functions

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
Jul 21 '05 #1
6 1466
Hi

You sure can do that in .NET. Functional overloading is supported in .NET
Jul 21 '05 #2
Hello Gav,

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

Maher
ma***@fr.fm

"Gav" <sp**@spam.com> wrote in message
news:uw**************@TK2MSFTNGP09.phx.gbl...
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

Jul 21 '05 #3
Gav
How can I do this with web services methods? Its complaining about
MessageName custom attribute to specify unique names.

Thanks for the help
Gav

"Maher K. Al-Jendasi" <ma***@fr.fm> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hello Gav,

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

Maher
ma***@fr.fm

"Gav" <sp**@spam.com> wrote in message
news:uw**************@TK2MSFTNGP09.phx.gbl...
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


Jul 21 '05 #4
Cor
Hi Gav,

That is possible in all dotNet languages.

Cor
Jul 21 '05 #5
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/de...us/cpref/html/
frlrfSystemWebServicesWebMethodAttributeClassMessa geNameTopic.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.

Jul 21 '05 #6
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.

Jul 21 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: hokiegal99 | last post by:
A few questions about the following code. How would I "wrap" this in a function, and do I need to? Also, how can I make the code smart enough to realize that when a file has 2 or more bad...
99
by: David MacQuigg | last post by:
I'm not getting any feedback on the most important benefit in my proposed "Ideas for Python 3" thread - the unification of methods and functions. Perhaps it was buried among too many other less...
21
by: Rubén Campos | last post by:
I haven't found any previous message related to what I'm going to ask here, but accept my anticipated excuses if I'm wrong. I want to ask about the real usefulness of the 'inline' keyword. I've...
17
by: cwdjrxyz | last post by:
Javascript has a very small math function list. However there is no reason that this list can not be extended greatly. Speed is not an issue, unless you nest complicated calculations several levels...
2
by: Bryan Olson | last post by:
The current Python standard library provides two cryptographic hash functions: MD5 and SHA-1 . The authors of MD5 originally stated: It is conjectured that it is computationally infeasible to...
7
by: Tim ffitch | last post by:
Hi I have created a VB dll file that contains common functions I use across various projects in VB, Access and Excel. Rather than have to code the functions in each I decided to use the dll...
23
by: Timothy Madden | last post by:
Hello all. I program C++ since a lot of time now and I still don't know this simple thing: what's the problem with local functions so they are not part of C++ ? There surely are many people...
14
by: v4vijayakumar | last post by:
Why we need "virtual private member functions"? Why it is not an (compile time) error?
7
by: Immortal Nephi | last post by:
My project grows large when I put too many member functions into one class. The header file and source code file will have approximately 50,000 lines when one class contains thousand member...
6
KevinADC
by: KevinADC | last post by:
This snippet of code provides several examples of programming techniques that can be applied to most programs. using hashes to create unique results static variable recursive function...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.