Wrox Programmer Forums
|
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 6th, 2005, 06:38 AM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post
Default

Quote:
quote:Originally posted by planoie
 ...What you are showing is:
1) We have interface 'IMyItf' (with 'int Func(int i,int j)')
2) Class 'Base1' implements 'IMyItf.Func()'
3) 'Derived' inherits from Base1
4) 'Derived' reimplements the method 'Func()'.

Is the intent of 'Derived.Func' to override 'Base1.Func'?...
Here's what I tried in VB:

Imports System
Public Interface IMyItf
    Sub MyMethod()
End Interface
Public Class Base1
    Implements IMyItf
    Public Overridable Sub MyMethod() Implements IMyItf.MyMethod
        Console.WriteLine("Base1.MyMethod")
    End Sub
End Class
Public Class Derived : Inherits Base1
    Public Overrides Sub MyMethod()
        Console.WriteLine("Derived.MyMethod")
    End Sub
End Class
Class 'Base1' implements 'IMyItf.Func()' expilictly(privately) therefore you cant use polymorphism in your
VB.NET code because it is a private function,so you have to re-implement the interface in Derived
class but in VB.NET you cant,
Quote:
quote:Originally posted by mehdi62b
 ...mainly VB.NET doesnt let us reimplement interfaces in subclasses,maybe you notice me why your example implements the interface in Base class explicitly,the answer is sometimes maybe we want to use some classes in .NET framework and we should extend them,but some interfaces have been implemented explicitly(private) so we have to implement them in Derived class,but as I mentioned VB.NET compiler throws an error:
Interface 'IMyItf' is already implemented by base class 'Base1'.
(for example take a look at this link,http://weblogs.asp.net/fbouma/archiv.../12/37199.aspx)...
sometimes you may need to implement some procedures of an interface in your base class privately,so if you want to derive
another class and use those private procedures,you should re-implement your interface in your derived class,
but in VB.NET(1.1) you cant.

_____________________________
Mehdi.
software engineering student.
Looking for a good job for summer 2005.
 
Old May 6th, 2005, 11:08 AM
Authorized User
 
Join Date: May 2005
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to subhasis.chakraborty Send a message via Yahoo to subhasis.chakraborty
Default

Hello friend if u re hassling about VB.NET and C#.NET , where can u overload an operator other than C# and in the other part where can u write a such managed and easy code with so much usable functions other than VB.NET ........





Similar Threads
Thread Thread Starter Forum Replies Last Post
vb.net 2008 re: VB.NET databases book bigbearjeff VB.NET 0 June 2nd, 2008 01:22 PM
convert dsr file from vb to vb.net Shashi001 VB Components 1 September 22nd, 2006 12:24 PM
VB.Net question on Windows VB.Net datagrids dmsousa VS.NET 2002/2003 1 January 19th, 2005 02:45 PM
vb.net 2002 OR vb.net 2003 metalaaron VB.NET 2002/2003 Basics 0 August 5th, 2003 10:00 AM
vb.net 2002 - vb.net 2003 book metalaaron Wrox Book Feedback 0 August 2nd, 2003 10:46 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.