I have an array and was wondering whether it was possible to go through the array and delete all the elements that are equal to NULL? If not the would it be possible to do it if i used a List(of T) instead of an array?
Printable View
I have an array and was wondering whether it was possible to go through the array and delete all the elements that are equal to NULL? If not the would it be possible to do it if i used a List(of T) instead of an array?
You can't delete items from the Array, once you initialize the array you can't change the size except with the "Redim" operator which will delete all values not just the null ones
So would you suggest using a list(of T) instead then? Or is there some other way to achieve what i want?
List(Of T) is a good method, but it all depends on what do you want to do!!
I have a thread that is controlled by a timer. This thread downloads an XML file everytime the timer ticks and stores the information from the XML file into an array. Now when the timer ticks and another XML file is downloaded then the elements in the array were being replaced so i created another array to copy all the elements of the first array and then jus kept copying across everytime the timer ticked. But it kept copying all the elements of the first array that had nothing in them so i would get an array which had the following element entries:
arrayElement(0) = nothing
arrayElement(1) = something
arrayElement(2) = nothing
arrayElement(3) = something
arrayElement(4) = nothing
etc.....
so i needed another way to store it so that i didn't keep getting elements with nothing in them.
Would this still happen if i use list(of T)?
If you use lists, you can add and remove items easily