I have the following problem. I derived a class from
ArrayList to provide some additional events I need. Then
I derived 2 different classes from this one and each of
them defines an indexer that returns the specified
object. For example, the list for Group types will have:
public new Group this[int index]
{
get
{return (Group)base[index];}
set
{base[index]=value;}
}
everything is fine, but if I do this:
someclass.Group s[0]. -> at this moment the members of the
Group object (returned by the indexer) do not show in the
intellisense drop down box. I know this is because the
ide "thinks" that the indexer returns the base item which
is object, or maybe because it doesn't know which one to
pick? However, this behaviour is pretty annoying and I
was wondering if anybody has any idea about what do I do
wrong?
Again, the list is derived directly from ArrayList and
then 2 different lists are derived from it and each list
implements the indexer that returns the required type.
Any help would be appreciated,
thank you!
Iulian 1 1635
Iulian,
How is the someclass variable defined?
Instead of deriving from ArrayList have you considered deriving from
System.Collecti ons.CollectionB ase instead?
CollectionBase contains an ArrayList internally yet allows you to define
fully functional type safe collections (new/shadows on methods not
required).
Hope this helps
Jay
"Iulian Ionescu" <iu************ @world-link.net> wrote in message
news:33******** *************** *****@phx.gbl.. . I have the following problem. I derived a class from ArrayList to provide some additional events I need. Then I derived 2 different classes from this one and each of them defines an indexer that returns the specified object. For example, the list for Group types will have:
public new Group this[int index] { get {return (Group)base[index];} set {base[index]=value;} }
everything is fine, but if I do this:
someclass.Group s[0]. -> at this moment the members of the Group object (returned by the indexer) do not show in the intellisense drop down box. I know this is because the ide "thinks" that the indexer returns the base item which is object, or maybe because it doesn't know which one to pick? However, this behaviour is pretty annoying and I was wondering if anybody has any idea about what do I do wrong?
Again, the list is derived directly from ArrayList and then 2 different lists are derived from it and each list implements the indexer that returns the required type.
Any help would be appreciated, thank you! Iulian This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Bill Cohagan |
last post by:
I'm trying to figure out the "best" way to implement a strongly typed
ArrayList. Using inheritance is one approach. It has the advantage that I
only have to write overrides for the Add method and indexer. There are
problems with this however. First the indexer "override" has a different
return type. This doesn't cause a compile time error, but using the indexer
doesn't seem to produce a properly typed expression. The Add override must...
|
by: thechaosengine |
last post by:
Hi all,
Is there a way to hide a member in a subclass that has been inherited from a
base class?
Lets leave aside any issues regarding whether its a good idea for a moment.
Here's an example similar to what I'm thinking about.
Lets suppose I make a class called RoleCollection.
|
by: Bob Weiner |
last post by:
What I want to be able to do is create an indexer that can index into an
ArrayList filled with objects of my own type. I have the following class
structure:
----------------------------------------------
class PropertyList : ArrayList {
public enum SortOrder { }
public object this { // cannot figure this one
t }
|
by: Steph |
last post by:
I'm learning C#. I need to implement an indexer using an array list. I have
the following code and I'm getting an error "Inconsistent accessibility:
indexer return type CRegs is less accessible than indexer Whouse.this.
Would someone please tell me why?
public class Whouse : IEnumerable
public CRegs this // Indexer
{
get
|
by: JJ |
last post by:
Hi,
I have created an Arraylist object from an Arraylist class.
I added rows to the arraylist object and I need to find a particular record
in my arraylist. How do I do this? Also if I was in the middle of building
the arraylist and wanted to call the last record added to arraylist object
how can I do this?
Thanks,
| |
by: Peter Oliphant |
last post by:
I just discovered that the ImageList class can't be inherited. Why? What
could go wrong? I can invision a case where someone would like to add, say,
an ID field to an ImageList, possible so that the individual elements in an
array of ImageList's could be identified by the ID, thereby allowing
re-ordering the array without harm. A person could identify by index into
the array, but that would not be preserved by re-ordering (and re-ordering...
|
by: Walt Zydhek |
last post by:
Could someone tell me how to Change the parameter type for an override of an
inherited class member? In particular, I would like to change an indexer for
my class that implements the IList class. Such as this:
public abstract class myclass : IList
{
private ArrayList ary;
....
public string this
|
by: lovecreatesbea... |
last post by:
Could you tell me how many class members the C++ language synthesizes
for a class type? Which members in a class aren't derived from parent
classes?
I have read the book The C++ Programming Language, but there isn't a
detail and complete description on all the class members, aren't they
important to class composing? Could you explain the special class
behavior in detail? Thank you very much.
|
by: Guy |
last post by:
Is there a better way to search identical elements in a sorted array
list than the following:
iIndex = Array.BinarySearch( m_Array, 0, m_Array.Count,
aSearchedObject );
aFoundObject= m_Array;
m_ResultArray.Add ( aFoundObject);
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |