PC Review


Reply
Thread Tools Rate Thread

Is deriving from HybridDictionary possible?

 
 
Paul Tomlinson
Guest
Posts: n/a
 
      24th Mar 2005
All, I have a very simple class and all I want to do is override the add and
remove methods for logging, thats it.
This is my class, however the only methods which I can override are equals,
gethashcode and tostring.

Why can't I override add and remove?


using System;
using System.Collections.Specialized;
namespace myApp
{
/***************************************************************************/
// CustomHybridDictionary
/***************************************************************************/
public class CustomHybridDictionary : HybridDictionary
{
/***************************************************************************/
// default constructor
/***************************************************************************/
public CustomHybridDictionary()
{
}
}
}


 
Reply With Quote
 
 
 
 
Jianwei Sun
Guest
Posts: n/a
 
      24th Mar 2005
Paul Tomlinson wrote:
> All, I have a very simple class and all I want to do is override the add and
> remove methods for logging, thats it.
> This is my class, however the only methods which I can override are equals,
> gethashcode and tostring.
>
> Why can't I override add and remove?
>
>
> using System;
> using System.Collections.Specialized;
> namespace myApp
> {
> /***************************************************************************/
> // CustomHybridDictionary
> /***************************************************************************/
> public class CustomHybridDictionary : HybridDictionary
> {
> /***************************************************************************/
> // default constructor
> /***************************************************************************/
> public CustomHybridDictionary()
> {
> }
> }
> }
>
>


The compiler message explains it goog enough.


error CS0506: 'QuickTest1.CustomHybridDictionary.Add(object, object)' :
cannot override inherited member
'System.Collections.Specialized.HybridDictionary.Add(object, object)'
because it is not marked virtual, abstract, or override

However, you can mark it "new", this will compile, just be sure this is
not "override" anymore, it means, when you create a base class and point
to the CustomHybridDictionary , it won't call the Add method in your class.

John.
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Get Last in HybridDictionary? localhost Microsoft Dot NET Framework 3 13th Jan 2005 10:19 PM
Sorting a HybridDictionary Object Paul Microsoft VB .NET 0 7th Oct 2004 03:09 PM
Sorting a HybridDictionary Object Paul Microsoft Dot NET 0 7th Oct 2004 03:09 PM
Sorting a HybridDictionary Object Paul Microsoft Dot NET Framework 0 7th Oct 2004 03:09 PM
HybridDictionary William Stacey [MVP] Microsoft C# .NET 3 4th Jun 2004 12:34 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:34 PM.