PDA

Click to See Complete Forum and Search --> : Interface question.


Wokawidget
Feb 2nd, 2006, 03:08 PM
VB.NET

Public Interface Woof

Public Function Msg As String

End Interface



Public Class User
Implements Woof

Public Function Status() As String Handles Woof.Msg
Return "Not good!"
End Function


In c# I have:

public interface iDisplayObjects
{
IEnumerator GetEnumerator();
}


then


public class Users: iDisplayObjects
{


I have a function in the Users class called GetEnumerator already, how can I make this function to be ALSO the interface function like in my vb example above?

Woof

jmcilhinney
Feb 2nd, 2006, 06:04 PM
I've never implemented an interface in C# before btu I was just playing around with doing so in C# 2005 Express. When you declare a class as implementing an interface Intellisense springs into action. It gives you the options "Implement inteface 'ISomething'" and "Explicitly implement interface 'ISomething'". The first option creates the appropriate member declarations with the appropriate names. The second does the same but qualifies the member names with "ISomething.". I guess C# doesn't require you to implement interface members explicitly like VB.NET does but it does allow you to. I would think that the explicit option would be preferable, if only for clarity. Perhaps someone else knows of some other reason that one method is better than the other.

Wokawidget
Feb 2nd, 2006, 07:17 PM
2005 ide is MUCH better than 2003 :D

Anyways, if you look here:

http://www.vbforums.com/showthread.php?t=385190

This is the fruits of my 2 days hard c# learning with thanks to you guys :D

Covers many different aspects of "good" development etc balh blah

woof