473,394 Members | 2,168 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,394 software developers and data experts.

Synchronizing a ListDictionary

Hi,

I tried to extend ListDictionary in order to create a thread safe version
named SynchronizedListDictionary.

Despite the docs saying the properties and methods of ListDictionary are
virtual, when I try to compile my derived class, the compiler tells me that
I "cannot override inherited member XXX because it is not marked virtual,
abstract, or override".

I know there are other collections and techniques that I can use as an
alternative, but I want to understand how a method can be listed as virtual
in the docs (which I thought came straight from the source) but the compiler
doesnt recognize it as such.

Thanks

Regards
Allen
Nov 15 '05 #1
6 2771
Try using "new". It doesn't override the virtual method, but it will be
called when referenced in the context of your customized class.

Jon
"Allen Jones" <ag*@bigfoot.com> wrote in message
news:eW**************@TK2MSFTNGP12.phx.gbl...
Hi,

I tried to extend ListDictionary in order to create a thread safe version
named SynchronizedListDictionary.

Despite the docs saying the properties and methods of ListDictionary are
virtual, when I try to compile my derived class, the compiler tells me that I "cannot override inherited member XXX because it is not marked virtual,
abstract, or override".

I know there are other collections and techniques that I can use as an
alternative, but I want to understand how a method can be listed as virtual in the docs (which I thought came straight from the source) but the compiler doesnt recognize it as such.

Thanks

Regards
Allen

Nov 15 '05 #2
Hi Jon,

Thanks for the input, but as I said in my post, I am not after work arounds
or alternatives. I want to understand why this does not work the way it
should.

Regards
Allen

"Jon Davis" <jo*@REMOVE.ME.PLEASE.jondavis.net> wrote in message
news:us**************@tk2msftngp13.phx.gbl...
Try using "new". It doesn't override the virtual method, but it will be
called when referenced in the context of your customized class.

Jon
"Allen Jones" <ag*@bigfoot.com> wrote in message
news:eW**************@TK2MSFTNGP12.phx.gbl...
Hi,

I tried to extend ListDictionary in order to create a thread safe version named SynchronizedListDictionary.

Despite the docs saying the properties and methods of ListDictionary are
virtual, when I try to compile my derived class, the compiler tells me

that
I "cannot override inherited member XXX because it is not marked virtual, abstract, or override".

I know there are other collections and techniques that I can use as an
alternative, but I want to understand how a method can be listed as

virtual
in the docs (which I thought came straight from the source) but the

compiler
doesnt recognize it as such.

Thanks

Regards
Allen


Nov 15 '05 #3
On Sat, 19 Jul 2003 15:42:01 +0100, "Allen Jones" <ag*@bigfoot.com>
wrote:
Hi,

I tried to extend ListDictionary in order to create a thread safe version
named SynchronizedListDictionary.

Despite the docs saying the properties and methods of ListDictionary are
virtual, when I try to compile my derived class, the compiler tells me that
I "cannot override inherited member XXX because it is not marked virtual,
abstract, or override".

I know there are other collections and techniques that I can use as an
alternative, but I want to understand how a method can be listed as virtual
in the docs (which I thought came straight from the source) but the compiler
doesnt recognize it as such.

Thanks

Regards
Allen


How did you override it? Using VS2003, this works:
public class MyDict:ListDictionary,IDictionary
{
public MyDict()
{
}
private class myDict:IDictionary
}
When you type myDict:IDictionary, VS will show a little tip that says:
"Press TAB to implement stubs for interface
System.Collections.IDictionary"

Does that work for you?
Nov 15 '05 #4
Austin,

Its the individual members that cause a problem when I compile them. e.g.

public class SynchronizedListDictionary : ListDictionary {

// other stuff

public override void Add(object key, object value) {
// method implementation
}
}

In the example the Add method causes the compiler to report the message:
Add(object, object) canot override
System.Collections.Specialized.ListDictionary.Add( object,object) because it
is not marked virtual, abstract, or override.

The problem is, according to the docs, ListDictionary.Add IS virtual.

Regards
Allen

"Austin Ehlers" <th***********************@hotmail.com> wrote in message
news:8g********************************@4ax.com...
On Sat, 19 Jul 2003 15:42:01 +0100, "Allen Jones" <ag*@bigfoot.com>
wrote:
Hi,

I tried to extend ListDictionary in order to create a thread safe version
named SynchronizedListDictionary.

Despite the docs saying the properties and methods of ListDictionary are
virtual, when I try to compile my derived class, the compiler tells me thatI "cannot override inherited member XXX because it is not marked virtual,
abstract, or override".

I know there are other collections and techniques that I can use as an
alternative, but I want to understand how a method can be listed as virtualin the docs (which I thought came straight from the source) but the compilerdoesnt recognize it as such.

Thanks

Regards
Allen


How did you override it? Using VS2003, this works:
public class MyDict:ListDictionary,IDictionary
{
public MyDict()
{
}
private class myDict:IDictionary
}
When you type myDict:IDictionary, VS will show a little tip that says:
"Press TAB to implement stubs for interface
System.Collections.IDictionary"

Does that work for you?

Nov 15 '05 #5
Yes, I have tried it & I agree there seems to be a discrepancy between the
docs and real life.

I appreciate you are not looking for workarounds, but just for information,
you can override the interface explicitly i.e.:

void IDictionary.Add(object key, object value);

However, this may not be ideal in all circumstances.

S.

"Allen Jones" <ag*@bigfoot.com> wrote in message
news:e4**************@TK2MSFTNGP10.phx.gbl...
Austin,

Its the individual members that cause a problem when I compile them. e.g.

public class SynchronizedListDictionary : ListDictionary {

// other stuff

public override void Add(object key, object value) {
// method implementation
}
}

In the example the Add method causes the compiler to report the message:
Add(object, object) canot override
System.Collections.Specialized.ListDictionary.Add( object,object) because it is not marked virtual, abstract, or override.

The problem is, according to the docs, ListDictionary.Add IS virtual.

Regards
Allen

"Austin Ehlers" <th***********************@hotmail.com> wrote in message
news:8g********************************@4ax.com...
On Sat, 19 Jul 2003 15:42:01 +0100, "Allen Jones" <ag*@bigfoot.com>
wrote:
Hi,

I tried to extend ListDictionary in order to create a thread safe versionnamed SynchronizedListDictionary.

Despite the docs saying the properties and methods of ListDictionary arevirtual, when I try to compile my derived class, the compiler tells me thatI "cannot override inherited member XXX because it is not marked virtual,abstract, or override".

I know there are other collections and techniques that I can use as an
alternative, but I want to understand how a method can be listed as virtualin the docs (which I thought came straight from the source) but the compilerdoesnt recognize it as such.

Thanks

Regards
Allen


How did you override it? Using VS2003, this works:
public class MyDict:ListDictionary,IDictionary
{
public MyDict()
{
}
private class myDict:IDictionary
}
When you type myDict:IDictionary, VS will show a little tip that says:
"Press TAB to implement stubs for interface
System.Collections.IDictionary"

Does that work for you?


Nov 15 '05 #6
Well. looking at the rotor source code, it does appear that the
documentation is wrong. It's declared as:

public void Add(object key, object value)
{
//stuff
}

So, it's another error in the documentation.
On Mon, 21 Jul 2003 09:19:32 +0100, "Allen Jones" <ag*@bigfoot.com>
wrote:
Austin,

Its the individual members that cause a problem when I compile them. e.g.

public class SynchronizedListDictionary : ListDictionary {

// other stuff

public override void Add(object key, object value) { // method implementation
}
}

In the example the Add method causes the compiler to report the message:
Add(object, object) canot override
System.Collections.Specialized.ListDictionary.Add (object,object) because it
is not marked virtual, abstract, or override.

The problem is, according to the docs, ListDictionary.Add IS virtual.

Regards
Allen

"Austin Ehlers" <th***********************@hotmail.com> wrote in message
news:8g********************************@4ax.com.. .
On Sat, 19 Jul 2003 15:42:01 +0100, "Allen Jones" <ag*@bigfoot.com>
wrote:
>Hi,
>
>I tried to extend ListDictionary in order to create a thread safe version
>named SynchronizedListDictionary.
>
>Despite the docs saying the properties and methods of ListDictionary are
>virtual, when I try to compile my derived class, the compiler tells methat >I "cannot override inherited member XXX because it is not marked virtual,
>abstract, or override".
>
>I know there are other collections and techniques that I can use as an
>alternative, but I want to understand how a method can be listed asvirtual >in the docs (which I thought came straight from the source) but thecompiler >doesnt recognize it as such.
>
>Thanks
>
>Regards
>Allen
>


How did you override it? Using VS2003, this works:
public class MyDict:ListDictionary,IDictionary
{
public MyDict()
{
}
private class myDict:IDictionary
}
When you type myDict:IDictionary, VS will show a little tip that says:
"Press TAB to implement stubs for interface
System.Collections.IDictionary"

Does that work for you?


Nov 15 '05 #7

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

Similar topics

3
by: Keith Veleba | last post by:
Hello to all fellow c.l.p'ers! Long-time listener, first-time caller. Background: I'm working on a project where I have to do some serious multithreading. I've worked up a decorator in Python...
0
by: Jim Douglas | last post by:
{System.Collections.Specialized.ListDictionary.NodeKeyValueCollection} : {System.Collections.Specialized.ListDictionary.NodeKeyValueCollection} Count: 25 ?entry.Contains("MachineName") ...
4
by: Doug | last post by:
I'm trying to create a user control that would have a ListDictionary property. When trying to use the property and set values for this collection, the dialog box that appears has everything...
0
by: Bas Gooijen | last post by:
hey all, my custom control has a property of type ListDictionary, and i want the designer to store the values in the InitializeComponent section. so that the values persist when loading/saving...
2
by: Doug | last post by:
Not that I'd actually do this... but knowing the answer would give me a bit more understanding of the .NET Framework and the base class libraries - specifically how things work in relation to my...
0
by: Gabriel Cirera | last post by:
Hello, Is it possible to fill a DataGrid with a ListDictionary? I tried to find the solution in this groups but I couldn't... Maybe is not possible.. who knows. I suppose it has to be some way...
2
by: Christopher D. Wiederspan | last post by:
We are getting ready to move an ASP.NET application off of a single development machine and onto a "webfarm". Basically our webfarm is a bunch of identical servers with the load-balancing provided...
2
by: SK | last post by:
Hello, I am trying to convert an object to a ListDictionary, but I get always the error: Specified cast is not valid. Here is my code: Private Property StoredProcedureParams() As...
0
by: Phil Galey | last post by:
I have a ListDictionary, from which I need to get an array of the keys and an array of the values, so I can Join() each to a delimited string. However, the Keys and Values properties are both...
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: 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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.