Remove blank values from array using C#

前端 未结 4 1789
陌清茗
陌清茗 2020-12-13 23:20

How can I remove blank values from an array?

For example:

string[] test={"1","","2","","3"};
<         


        
4条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-14 00:20

    I write below code to remove the blank value in the array string.

    string[] test={"1","","2","","3"};
    test= test.Except(new List { string.Empty }).ToArray();
    

提交回复
热议问题