I have a program where an array gets its data using string.Split(char[] delimiter). (using ';' as delimiter.)
Some of the values, though, are null. I.e. the string has parts where there is no data so it does something like this:
1 ;2 ; ; 3;
This leads to my array having null values.
How do I get rid of them?
You should replace multiple adjacent semicolons with one semicolon before splitting the data.
This would replace two semicolons with one semicolon:
But, if you have more than two semicolons together, regex would be better.
You could use the Where linq extension method to only return the non-null or empty values.
charseparators is a space
Try this: