473,378 Members | 1,396 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Overriding Hashtable.Add method

MSDN and intellisense shows the Add method of Hashtable being overridable
however when I use this code:

Public Class RAL
Inherits Hashtable

Public Overrides Sub Add(ByVal Key As String, ByVal Value As Object)

End Sub
I get the following 2 errors indicating that Add is Overloadable instead of
Overridable:

sub 'Add' cannot be declared 'Overrides' because it does not override a sub
in a base class.

sub 'Add' shadows an overloadable member declared in the base class
'Hashtable'. If you want to overload the base method, this method must be
declared 'Overloads'.
If possible I need to override this. Any suggestions appreciated.
Thanks,
John
Nov 21 '05 #1
6 5389
Overriding it, means overriding it with the exact same signature method.
You have changed the type of the first parameter - therefore it would be
overloading the method.

"John Cobb" <jo*******@acxiom.com> wrote in message
news:OX**************@TK2MSFTNGP15.phx.gbl...
MSDN and intellisense shows the Add method of Hashtable being overridable
however when I use this code:

Public Class RAL
Inherits Hashtable

Public Overrides Sub Add(ByVal Key As String, ByVal Value As Object)

End Sub
I get the following 2 errors indicating that Add is Overloadable instead of Overridable:

sub 'Add' cannot be declared 'Overrides' because it does not override a sub in a base class.

sub 'Add' shadows an overloadable member declared in the base class
'Hashtable'. If you want to overload the base method, this method must be
declared 'Overloads'.
If possible I need to override this. Any suggestions appreciated.
Thanks,
John

Nov 21 '05 #2
Nak
Hi John,

Parameter "Key" must be of type "Object". Select "(Overrides)" from the
Class dropdown box above the text editor and then "Add" from the other
dropdown, this assures that the method has the same signature.

Nick.

"John Cobb" <jo*******@acxiom.com> wrote in message
news:OX**************@TK2MSFTNGP15.phx.gbl...
MSDN and intellisense shows the Add method of Hashtable being overridable
however when I use this code:

Public Class RAL
Inherits Hashtable

Public Overrides Sub Add(ByVal Key As String, ByVal Value As Object)

End Sub
I get the following 2 errors indicating that Add is Overloadable instead
of
Overridable:

sub 'Add' cannot be declared 'Overrides' because it does not override a
sub
in a base class.

sub 'Add' shadows an overloadable member declared in the base class
'Hashtable'. If you want to overload the base method, this method must be
declared 'Overloads'.
If possible I need to override this. Any suggestions appreciated.
Thanks,
John

Nov 21 '05 #3
> Public Overrides Sub Add(ByVal Key As String, ByVal Value As Object)

The Add method of the hashtable has both its arguments as 'Object'. You
cannot change the signature of a method when overriding it - you can only
change its implementation.
Imran.
Nov 21 '05 #4
John,
In addition to the other comments:

Rather then attempt to inherit from Hashtable, consider inheriting from
DictionaryBase.

As DictionaryBase wraps a Hashtable allowing you to put type safe methods on
your derived class.

Hope this helps
Jay

"John Cobb" <jo*******@acxiom.com> wrote in message
news:OX**************@TK2MSFTNGP15.phx.gbl...
MSDN and intellisense shows the Add method of Hashtable being overridable
however when I use this code:

Public Class RAL
Inherits Hashtable

Public Overrides Sub Add(ByVal Key As String, ByVal Value As Object)

End Sub
I get the following 2 errors indicating that Add is Overloadable instead
of
Overridable:

sub 'Add' cannot be declared 'Overrides' because it does not override a
sub
in a base class.

sub 'Add' shadows an overloadable member declared in the base class
'Hashtable'. If you want to overload the base method, this method must be
declared 'Overloads'.
If possible I need to override this. Any suggestions appreciated.
Thanks,
John

Nov 21 '05 #5
Hi,

To create a custom collection you inherit from collectionbase.
To create a custom hastable inherit from DictionaryBase.

http://msdn.microsoft.com/library/de...classtopic.asp

Ken
---------------
"John Cobb" <jo*******@acxiom.com> wrote in message
news:OX**************@TK2MSFTNGP15.phx.gbl...
MSDN and intellisense shows the Add method of Hashtable being overridable
however when I use this code:

Public Class RAL
Inherits Hashtable

Public Overrides Sub Add(ByVal Key As String, ByVal Value As Object)

End Sub
I get the following 2 errors indicating that Add is Overloadable instead of
Overridable:

sub 'Add' cannot be declared 'Overrides' because it does not override a sub
in a base class.

sub 'Add' shadows an overloadable member declared in the base class
'Hashtable'. If you want to overload the base method, this method must be
declared 'Overloads'.
If possible I need to override this. Any suggestions appreciated.
Thanks,
John

Nov 21 '05 #6
Thanks for all the quick informative replies. I inherited from
DictionaryBase rather than Hashtable as suggested and I've got a better,
more robust object. Thanks!

"John Cobb" <jo*******@acxiom.com> wrote in message
news:OX**************@TK2MSFTNGP15.phx.gbl...
MSDN and intellisense shows the Add method of Hashtable being overridable
however when I use this code:

Public Class RAL
Inherits Hashtable

Public Overrides Sub Add(ByVal Key As String, ByVal Value As Object)

End Sub
I get the following 2 errors indicating that Add is Overloadable instead of Overridable:

sub 'Add' cannot be declared 'Overrides' because it does not override a sub in a base class.

sub 'Add' shadows an overloadable member declared in the base class
'Hashtable'. If you want to overload the base method, this method must be
declared 'Overloads'.
If possible I need to override this. Any suggestions appreciated.
Thanks,
John

Nov 21 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Rafael Veronezi | last post by:
I have some questions about override in inheritance, and virtual members. I know that you can you override a method by two ways in C#, one, is overriding with the new keyword, like: public new...
4
by: David Hoffer | last post by:
Why is it that when I override Equals I get the following warning? What am I suppose to do? warning CS0659: 'XXX.MyObject' overrides Object.Equals(object o) but does not override...
33
by: Ken | last post by:
I have a C# Program where multiple threads will operate on a same Hashtable. This Hashtable is synchronized by using Hashtable.Synchronized(myHashtable) method, so no further Lock statements are...
17
by: Bob Weiner | last post by:
What is the purpose of hiding intead of overriding a method? I have googled the question but haven't found anything that makes any sense of it. In the code below, the only difference is that...
3
by: pagates | last post by:
Hello Gurus, I have a listview, and I only want to add unique items. The problem is, my code is blowing by my "Contains" statement, adding the item, and then hitting my Compare code in the...
7
by: ad | last post by:
I have a hash table like: Hashtable myHT = new Hashtable(); myHT.Add("First", "Hello"); myHT.Add("Second", "World"); myHT.Add("Third", "!"); We can use key to find value like: myHT -> "Hello"...
12
by: Rubbrecht Philippe | last post by:
Hi there, According to documentation I read the ArrayList.IndexOf method uses the Object.Equals method to loop through the items in its list and locate the first index of an item that returns...
18
by: JohnR | last post by:
From reading the documentation, this should be a relatively easy thing. I have an arraylist of custom class instances which I want to search with an"indexof" where I'm passing an instance if the...
10
by: r035198x | last post by:
The Object class has five non final methods namely equals, hashCode, toString, clone, and finalize. These were designed to be overridden according to specific general contracts. Other classes that...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.