473,406 Members | 2,220 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,406 software developers and data experts.

Overloading methods in interface declarations

I have an interface that contains definintions for a method with two
different signatures. For example:

namespace Paul.DemoApp
{
public interface IHello
{
void sayHello(string message, Thing myThing);

void sayHello(string message, DemoClass demo);
}
}

I then implement the interface. In Visual Studio 7, if I press TAB to create
the methods, it produces something like this:

public class HelloWorld : IHello
{
public void sayHello(string message, Thing myThing)
{
...
}

void Paul.DemoApp.IHello sayHello(string message, DemoClass demo)
{
...
}

}

The second method is created with an explicit name including the namespace.
I can 'fix' it by removing the namespace and adding the "public" access
specifer, which is what I expected to be generated in the first place.

Can anyone explain why Visual Studio generates code like the above example?

Thanks,

Paul.
Nov 16 '05 #1
2 1387
> The second method is created with an explicit name including the
namespace.
I can 'fix' it by removing the namespace and adding the "public" access
specifer, which is what I expected to be generated in the first place.

Can anyone explain why Visual Studio generates code like the above

example?
It is certainly a Bug. This also happens to me sometimes.

--
cody

Freeware Tools, Games and Humour
http://www.deutronium.de.vu || http://www.deutronium.tk
Nov 16 '05 #2
It is a bug, sort of. My colleague happened upon a blog from one of the C#
team at Microsoft which states that the implicit/ explicit behaviour was
intentional, but it causes the problem stated here now and again:

"In 2003 we attempted to intelligently choose whether to implement the
interface implicitly or explicitly. If there were existing members with the
same name but a different signature then we would implement that member
explicitly."

Read the rest of Anson Horton's article here:
http://blogs.msdn.com/ansonh/archive.../13/89185.aspx

Paul.

"cody" <no****************@gmx.net> wrote in message
news:u5**************@TK2MSFTNGP11.phx.gbl...
The second method is created with an explicit name including the

namespace.
I can 'fix' it by removing the namespace and adding the "public" access
specifer, which is what I expected to be generated in the first place.

Can anyone explain why Visual Studio generates code like the above

example?
It is certainly a Bug. This also happens to me sometimes.

--
cody

Freeware Tools, Games and Humour
http://www.deutronium.de.vu || http://www.deutronium.tk

Nov 16 '05 #3

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

Similar topics

17
by: Terje Slettebø | last post by:
To round off my trilogy of "why"'s about PHP... :) If this subject have been discussed before, I'd appreciate a pointer to it. I again haven't found it in a search of the PHP groups. The PHP...
18
by: Daniel Gustafsson | last post by:
Hi there, hmm, I've just started with C# and I'm experimenting with method overloading. It seems like it's not possible to override method using return types, only parameters. Is that by design,...
9
by: Karahan Celikel | last post by:
Here are three simple classes: class A { public void DoIt(B b) { DoSomething(b); } public void DoSomething(B b) {
11
by: placid | last post by:
Hi all, Is it possible to be able to do the following in Python? class Test: def __init__(self): pass def puts(self, str): print str
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.