G
Guest
I have a collectiond derived from NameObjectCollectionBase. FxCop is
complaining that I need to implement a strongly typed CopyTo(MyObjectType,
int)
How do I do this? I can't seem to find any implementations of CopyTo() that
don't rely on Array.Copy or some other internal .NET method. Unfortunately,
there's nothing I can find that will work for a NameObjectCollectionBase
derived class. I can't find any implementations of CopyTo() for
NameObjectCollectionBase derived classes out on google either.
The documentations doesn't really explain how CopyTo() is supposed to
function. The one thing that appears missing is an explanation of what
you're supposed to do if the index passed in is mid-way into the array. Do
you shift all the items out to make room or do you overwrite existing items?
I presume you shift them out.
I tried seeing how .NET implements it in similar collections using
Reflector. Unfortunately, all the implementations appear to be written in
unmanaged code, so I can't see how they're implemented.
Can anyone help me on this? I need to do it, I presume, for both the Keys
and the Values members. Also, there's no Insert() functionality in
NameObjectCollectionBase, so I'm not sure how to shift the elements out.
Thanks.
Pete Davis
complaining that I need to implement a strongly typed CopyTo(MyObjectType,
int)
How do I do this? I can't seem to find any implementations of CopyTo() that
don't rely on Array.Copy or some other internal .NET method. Unfortunately,
there's nothing I can find that will work for a NameObjectCollectionBase
derived class. I can't find any implementations of CopyTo() for
NameObjectCollectionBase derived classes out on google either.
The documentations doesn't really explain how CopyTo() is supposed to
function. The one thing that appears missing is an explanation of what
you're supposed to do if the index passed in is mid-way into the array. Do
you shift all the items out to make room or do you overwrite existing items?
I presume you shift them out.
I tried seeing how .NET implements it in similar collections using
Reflector. Unfortunately, all the implementations appear to be written in
unmanaged code, so I can't see how they're implemented.
Can anyone help me on this? I need to do it, I presume, for both the Keys
and the Values members. Also, there's no Insert() functionality in
NameObjectCollectionBase, so I'm not sure how to shift the elements out.
Thanks.
Pete Davis