Re: Defining methods for a class that are accessible when declaring arrays of that class???

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Bob Rock (nospam.yet_another_apprentice_at_hotmail.com)
Date: 06/01/04


Date: Tue, 1 Jun 2004 14:47:36 +0200


> This is not supported. The problem is you want to use an array of objects
as
> the object instance in the method call, and only a single instance can be
> specified. This instance is used as the object instance in the method
body.
> In other words, if your class defined a field, one per instance, then each
> object in the array would have its own copy of that field. In the method
> itself, if there was a reference to the field then it would be impossible
to
> determine which object instance you meant.
>
> Instead, you could define a static method that took an array of _A
objects.
>

David, I'm already using a static method that takes an array of my objects.
Still, I was wondering if there was some way of adding to the methods that
are available when using an array of my objects. I was thinking that this IS
an array, but IT IS an array of specific objects, so somehow it would be
possible to know what other methods should be made available on the array.

Anyhow I've seen that the methods available on any array are those defined
in the array abstract class and that these are implemented for each type in
the CLR. So somehow there must be a way of implementing the behavior of
these methods for an array of a custom class objects. I wonder just how.

Bob Rock



Relevant Pages