Showing results for 
Search instead for 
Do you mean 
Solved! Go to solution

TaggedObject [] and TaggedObject in c#

Hi Guys,

Is it possible to add a taggedObject to an Array of TaggedObject[].

Because the add function isn't available to the taggedObject[].


Thanks !

Accepted by topic author Ildon
‎06-02-2016 02:39 AM

Re: TaggedObject [] and TaggedObject in c#

You can use Array.Resize() -


Or, you could use ArrayLists, which are inherently dynamic, from the start -

Re: TaggedObject [] and TaggedObject in c#

ArrayLists are very flexible, but they are generally frowned upon these days. The problem is that they side-step strong typing, and they have some performance problems. If you don't care about these, then go ahead with an ArrayList.


Most people would recommend use of List(Of TaggedObject), instead. This is strongly typed, faster, and it has the "Add" method you wanted.


Re: TaggedObject [] and TaggedObject in c#

@Yamada is correct. I used the wrong name. The strongly typed list is a better choice, and is also easier to use when feeding a function that expects and array - the .ToArray() method returns an array of the correct type, eliminating any need for type casting.