There is a string array mas, the data of which must be saved in a txt file .

I delete empty strings with this method: mas.Where(n => !string.IsNullOrEmpty(n)); but in the end both full and empty lines are saved.

What is required for complete removal?

  • Well, it depends on how you delete. Most likely, the result of the Where method is not having any variable - DreamChild
  • And how can you assign a value? - Zeus
  • one
    You do not know how to assign values ​​to variables? Then it makes sense for you to read the very basics of the language - DreamChild

1 answer 1

 var array = new[] { "abc", "cde", "", " " }; var result = array.Where(x => !string.IsNullOrWhiteSpace(x)); File.WriteAllLines(@"c:\result.txt", result);