|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Can't Override Equals in .NET 1.1 using VBI am trying to override the Equals function in Object with VB 2003 (.NET 1.1) like this: Public Class Foo Public Overrides Function Equals(ByVal obj As Object) As Boolean Return True End Function End Class Visual Basic however gives me the following error: "function 'Equals' shadows an overloadable member declared in the base class 'Object'. If you want to overload the base method, this method must be declared 'Overloads'." This is very strange since Equals is defined as overridable and has exactly the same prototype in Object. Is this a bug in VB? Because this works fine in C# 2003 and in VB 2005. Gunnar Valur wrote:
> Visual Basic however gives me the following error: More of a "feature" - There are two overloads for Object.Equals; the one > > "function 'Equals' shadows an overloadable member declared in the base class > 'Object'. If you want to overload the base method, this method must be > declared 'Overloads'." > > This is very strange since Equals is defined as overridable and has exactly > the same prototype in Object. > > Is this a bug in VB? Because this works fine in C# 2003 and in VB 2005. you're trying to override and the Shared version that compares two, explicitly supplied Objects. /I think/ that because these two, supplied methods are declared as "Overloads", any Overrides that you write /also/ have to be declared as "Overloads", even though you don't actually care. HTH, Phill W. Show quoteHide quote > Thanks Phill,
Had just forgotten how illogical VB can sometimes be. At least this is fixed in VB 2005 |
|||||||||||||||||||||||