Results 1 to 7 of 7

Thread: [RESOLVED] little Q about implementing an interface's functions...

  1. #1

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428

    Resolved [RESOLVED] little Q about implementing an interface's functions...

    syntax issue here, suppose a class implements IDisposable, then are these two considered the same inside this class?
    Code:
    void IDisposable.Dispose()
    {}
    
    public void Dispose()
    {}
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  2. #2
    Frenzied Member axion_sa's Avatar
    Join Date
    Jan 2002
    Location
    Joburg, RSA
    Posts
    1,724

    Re: little Q about implementing an interface's functions...

    Not if you use a fully qualified prefix for interface method declarations, as you have. However, that being said, it isn't recommended

    [Edit]
    The above will only work if the method is inherited from a parent class - you will get a build warning ("modifier 'new' is needed").
    If you have explicitly defined your own Dispose method in the same class, you will get a build error.
    Last edited by axion_sa; Sep 2nd, 2005 at 12:55 PM.

  3. #3

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428

    Re: little Q about implementing an interface's functions...

    hmm so usually I see the first one on MSDN, you're saying it isnt recommended?

    also, what's the difference, I dont really understand kinda confused
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  4. #4
    Frenzied Member axion_sa's Avatar
    Join Date
    Jan 2002
    Location
    Joburg, RSA
    Posts
    1,724

    Re: little Q about implementing an interface's functions...

    Haven't noted anything like that in MSDN - may I ask where you found it?

    When I say not recommended, I mean that designing an application so that it will inherit specific method signatures that conflict with interface method signatures

    The difference between creating your own Dispose as opposed to implementing IDisposable? One imagines that when the .Net framework searches for Dispose implementations, it will search the inheritance / implementation routes used - i.e. search for IDisposable, and not Dispose itself. Although, if you're going to be calling Dispose yourself, I guess it's six of one...

  5. #5

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428

    Re: little Q about implementing an interface's functions...

    well look at this for example http://msdn.microsoft.com/library/de...classtopic.asp
    they use IDeserializationCallback.OnDeserialization

    both of the Dispose() ones I have above seem to do the same: implement the Dispose method of the IDisposable interface.
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  6. #6
    Frenzied Member axion_sa's Avatar
    Join Date
    Jan 2002
    Location
    Joburg, RSA
    Posts
    1,724

    Re: little Q about implementing an interface's functions...

    Oh! You mean using just the method name as opposed to fully qualifying it? Nope, no difference whatsoever.

    Sorry - seems I was barking up the wrong tree...

  7. #7

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428

    Re: little Q about implementing an interface's functions...

    lol yeah that's what I was asking

    hmm it's a bit more clear to use the fully qualifying name I guess
    thanks for the posts though... I was confusing as whether there was a difference or whether one was right or wrong
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

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