How can I remove blank values from an array?
For example:
string[] test={"1","","2","","3"};
in this case, is there any method available to remove blank values from the array using C#?
At the end, I want to get an array in this format:
test={"1","2","3"};
which means 2 values removed from the array and eventually I get 3.
If you are using .NET 3.5+ you could use LINQ (Language INtegrated Query).
test = test.Where(x => !string.IsNullOrEmpty(x)).ToArray();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With