Results 1 to 3 of 3

Thread: Interface question.

  1. #1

    Thread Starter
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Interface question.

    VB.NET
    Code:
    Public Interface Woof
    
        Public Function Msg As String
    
    End Interface
    Code:
    Public Class User
    Implements Woof
    
    Public Function Status() As String Handles Woof.Msg
        Return "Not good!"
    End Function
    In c# I have:
    Code:
    public interface iDisplayObjects
    {
    	IEnumerator GetEnumerator();
    }
    then

    Code:
    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

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Interface question.

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Re: Interface question.

    2005 ide is MUCH better than 2003

    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

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

    woof

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width