472,784 Members | 962 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

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 4675
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Medi Montaseri | last post by:
Hi, I think my problem is indeed "how to implement something like java's final in C++" The long version.... I have an abstract base class which is inherited by several concrete classes. I...
3
by: Erik Harris | last post by:
I apologize if this is a stupid question - I'm relatively new to OOP. I have a property that must exist in a class in order to be used by another class. The property, however, does not change with...
1
by: Pieter | last post by:
Hi, I have my own custom BindingList, that inherits from BindingList, and implements IComponent. I would like to implement a Find-method, that will allow me to search for a property of my...
7
by: moondaddy | last post by:
If I'm in a class that inherits an interface, is there a shortcut key that will write the implementation of the interface into the class? I remember seeing something like this in vb.net. ...
11
by: Manuel | last post by:
Hi, I need implement a map of member functions of some class. This map is formed by a string and a pointer to the member function. The problem is that the map need that the object saved are...
4
by: PenguinPig | last post by:
Dear Experts, Could you please provide you comment to me? Thanks An Exhibition has many Halls, and different Booth Types If exhibition is not exist, hall and booth type will not exist too. ...
0
by: emin.shopper | last post by:
I had a need recently to check if my subclasses properly implemented the desired interface and wished that I could use something like an abstract base class in python. After reading up on metaclass...
8
by: John | last post by:
Hi, gurus, How can I implement the following feature in C#: Set objGroup = GetObject("WinNT://" & strComputer & "/" & strGroup & ", group") For Each objMember In objGroup.Members...
5
by: Tony Johansson | last post by:
Hello! The only reason I can see interface to be implemented explicitly is when the a class implement two interface having the same method signature. In all other cases I can implement interface...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

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.