473,503 Members | 3,045 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1468
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
3326
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
5818
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
746
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
3588
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
3758
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
5877
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
3961
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
4166
by: v4vijayakumar | last post by:
Why we need "virtual private member functions"? Why it is not an (compile time) error?
7
3946
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
9593
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...
0
7193
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7067
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7316
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6975
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7449
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4666
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3160
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
728
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
371
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.