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

GetEnumerator and NameObjectCollectionBase

I've constructed a class that inherits the NameObjectCollectionBase
class. All works well, but I'd like to shadow the GetEnumerator method
so that it returns an actual value *instead of a DictionaryEntry*.

I've gotten strange errors when attempting to override GetEnumerator,
such as 'GetEnumerator() cannot override 'Public Overridable
NotOverridable Function GetEnumerator() because it is declared
NotOverridable......yes, it actually says it is *overridable
notoverridable*.

Any ideas why this would not work, and what I should do to "modify" my
GetEnumerator()?

--
================================================== ================
Sam J. Marrocco
Sr. Visual Effects Artist/R&D
Travelling Pictures/GTN
Inferno, Flame, Maya, All that cool stuff!
"The fact that no one understands you doesn't make you an artist."
================================================== ================

Nov 20 '05 #1
2 1548
Instead of Overridable, use Shadows. The one thing to be careful of is that
a Shadowed member only works for the type you declare it in.
For example, if you create class Customers by inheriting
NameObjectCollectionBase, then Shadow GetEnumerator on Customers, your
GetEnumerator will run only on references to Customers. References of type
NameObjectCollectionBase (for example) which point to an instance of
Customers will run the default GetEnumerator defined for
NameObjectCollectionBase.

-Rob Teixeira [MVP]

"Sam Marrocco" <sa*@twmi.rr.com> wrote in message
news:A7******************@fe2.columbus.rr.com...
I've constructed a class that inherits the NameObjectCollectionBase
class. All works well, but I'd like to shadow the GetEnumerator method
so that it returns an actual value *instead of a DictionaryEntry*.

I've gotten strange errors when attempting to override GetEnumerator,
such as 'GetEnumerator() cannot override 'Public Overridable
NotOverridable Function GetEnumerator() because it is declared
NotOverridable......yes, it actually says it is *overridable
notoverridable*.

Any ideas why this would not work, and what I should do to "modify" my
GetEnumerator()?

--
================================================== ================
Sam J. Marrocco
Sr. Visual Effects Artist/R&D
Travelling Pictures/GTN
Inferno, Flame, Maya, All that cool stuff!
"The fact that no one understands you doesn't make you an artist."
================================================== ================

Nov 20 '05 #2
Thanks, I'll try that!

Rob Teixeira [MVP] wrote:
Instead of Overridable, use Shadows. The one thing to be careful of is that

--
================================================== ================
Sam J. Marrocco
Sr. Visual Effects Artist/R&D
Travelling Pictures/GTN
Inferno, Flame, Maya, All that cool stuff!
"The fact that no one understands you doesn't make you an artist."
================================================== ================

Nov 20 '05 #3

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

Similar topics

1
by: Rein Petersen | last post by:
Hi Everyone! I hope someone may have experience serializing a NameObjectCollectionBase (System.Collections.Specialized) and can advise me as to why I receive this error (below) when I try to...
3
by: William Stacey [MVP] | last post by:
What is the deal with NameObjectCollectionBase? It allows duplication keys to be added to the hashtable using System; using System.Collections; using System.Collections.Specialized; ...
4
by: John C | last post by:
I'm new to C#, so just point me at the correct reference material if this question has been answered before. When creating a new class which implements the IDictionary interface, two versions of...
3
by: Sam Marrocco | last post by:
I've created a collection class that inherits the NameObjectCollectionBase. I'd like to add a few functions, such as being able to insert a new item at an indexed or keyed location in the...
2
by: Sam Marrocco | last post by:
I've created a collection class that inherits NameObjectCollectionBase (call it MyCollection). MyCollection is declared as serializable, and serializes fine. A cursory glance into the serialized...
2
by: Steve Richter | last post by:
very confused on how to implement the IEnumerable and IEnumerator interfaces on a generic type. I understand I should just use a foreach loop in the GetEnumerator method and use "yield return",...
2
by: =?Utf-8?B?VGVk?= | last post by:
I have been asked to change an existing program which Implemented a Collection Class The current class had what is below (its just a summary of the code) Public Class FieldList Implements...
16
by: colin | last post by:
Hi, is it possible to have a recursive GetEnumerator for traversing a tree structure ? public IEnumerator<DTypeGetEnumerator() { return GetEnumerator(root);
2
by: Tony | last post by:
Hello! According to the documentation we have the following interface IList : ICollection, IEnumerable { I can understand all the methods in this IList } interface ICollection : IEnumerable...
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:
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
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.