Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

give me C# equivalent code for this VB.NET code (related to Interfaces

Status
Not open for further replies.

amitreddy

Programmer
Sep 11, 2003
1
IN
Public Interface IConfirmable
Sub Confirm()
End Interface
Public Class WebSalesOrder()
Inherits SalesOrder
Implements IConfirmable
Public Sub Confirm() Implements IConfirmable.Confirm
' Code to confirm a web order
End Sub
' Other WebSalesOrder code
End Class

Public Class WebSalesOrder()
Inherits SalesOrder
Implements IConfirmable
Public Sub ConfirmWebOrder() Implements IConfirmable.Confirm *******
' Code to confirm a web order
End Sub


The code line which has *******, how do we change the name of the function in C#, ie I need an equivalent implementation in C#

Amit


Source :
 
Code:
 Public Sub ConfirmWebOrder() Implements IConfirmable.Confirm *******
should be:
Code:
Public Sub ConfirmWebOrder()
Because the class already implements your interface, the method whose name & parameter list matches will be part of that interface.

An easy way to do this is to add your inheritance to the class header:
Code:
Class WebSalesOrder() : SalesOrder, IConfirmable
{
Then go to the class viewer and find your class. Expand the tree so that "Bases & Interfaces" are shown. Pick your interface, then right-click and choose "Implement". The method templates will automatically be added to your class.

Chip H.


If you want to get the best response to a question, please check out FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top