Listbox, array, item deletion

S

Sweetiecakes

Hi

I have an string[] array containing file paths. I have added them to a
ListBox with AddRange();

When I delete an item from the ListBox, how can I delete the same item
from the original array?

Thanks
 
A

Ashutosh Bhawasinka

It's not possible. All you can do is to create an new array(leaving the
deleted string) and assign it to the same old array variable/field.
 
J

Jeff Johnson

I have an string[] array containing file paths. I have added them to a
ListBox with AddRange();

When I delete an item from the ListBox, how can I delete the same item
from the original array?

Like Ashutosh said, there's no way to delete an arbitrary element from an
array. Next time consider using a List<string> instead and it will handle
removing items for you.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top