469,364 Members | 2,332 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,364 developers. It's quick & easy.

How to implement a method as different name

Hi guys,
How can i implement a method of interface in a new class as different method
name. Something like use Implement key word in VB.NET.

Thanks!
Feb 19 '07 #1
6 4264
You do not have that option in C#. Methods which implement interface methods
are recognized solely by signature.
--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C#/VB to C++ converter
Instant Python: C#/VB to Python converter
"Steven.Xu" wrote:
Hi guys,
How can i implement a method of interface in a new class as different method
name. Something like use Implement key word in VB.NET.

Thanks!
Feb 19 '07 #2
>You do not have that option in C#. Methods which implement interface
methods
are recognized solely by signature.
Let me add to this that you can use something called "explicit interface
implementation" in C#. This is useful in cases where there's naming
conflict between various methods - I actually use it a lot of the time
when implementing interfaces, instead of waiting for the conflict to appear.

See this MSDN page for details:

http://msdn2.microsoft.com/en-us/library/ms173157.aspx

Oliver Sturm
--
http://www.sturmnet.org/blog
Feb 21 '07 #3
You are still required to use the interface method name, although explicit
interface implementation does prevent most of the need for renaming in these
cases that would occur in VB.
--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C#/VB to C++ converter
Instant Python: C#/VB to Python converter
"Oliver Sturm" wrote:
>
You do not have that option in C#. Methods which implement interface
methods
are recognized solely by signature.

Let me add to this that you can use something called "explicit interface
implementation" in C#. This is useful in cases where there's naming
conflict between various methods - I actually use it a lot of the time
when implementing interfaces, instead of waiting for the conflict to appear.

See this MSDN page for details:

http://msdn2.microsoft.com/en-us/library/ms173157.aspx

Oliver Sturm
--
http://www.sturmnet.org/blog
Feb 21 '07 #4
Hello David,
>You are still required to use the interface method name, although explicit
interface implementation does prevent most of the need for renaming in
these
cases that would occur in VB.
I wasn't saying this does the same thing as the VB keyword the OP referred
to. I was trying to guess what the original intention was, and offering
explicit interface implementation as a possible solution.
Oliver Sturm
--
http://www.sturmnet.org/blog
Feb 21 '07 #5
Right - I was just elaborating on that ("...explicit interface implementation
does prevent most of the need for renaming...").
--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C#/VB to C++ converter
Instant Python: C#/VB to Python converter
"Oliver Sturm" wrote:
Hello David,
You are still required to use the interface method name, although explicit
interface implementation does prevent most of the need for renaming in
these
cases that would occur in VB.

I wasn't saying this does the same thing as the VB keyword the OP referred
to. I was trying to guess what the original intention was, and offering
explicit interface implementation as a possible solution.
Oliver Sturm
--
http://www.sturmnet.org/blog
Feb 21 '07 #6
Hello David,
>Right - I was just elaborating on that ("...explicit interface
implementation
does prevent most of the need for renaming...").
Right :-)
Oliver Sturm
--
http://www.sturmnet.org/blog
Feb 21 '07 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

14 posts views Thread by Medi Montaseri | last post: by
1 post views Thread by Pieter | last post: by
7 posts views Thread by moondaddy | last post: by
11 posts views Thread by Manuel | last post: by
4 posts views Thread by PenguinPig | last post: by
reply views Thread by emin.shopper | last post: by
8 posts views Thread by John | last post: by
5 posts views Thread by Tony Johansson | last post: by
1 post views Thread by CARIGAR | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.