string array.Contains?

前端 未结 10 1619
无人及你
无人及你 2021-02-07 03:22

.NET 2

string[] myStrings = GetMyStrings();    
string test = \"testValue\";

How can I verify if myStrings contains test

10条回答
  •  眼角桃花
    2021-02-07 04:01

    Instead of using a static array, you could use a List:

    List myStrings = new List(GetMyStrings());
    if(myStrings.Contains("testValue"))
    {
        // Do Work
    }
    

提交回复
热议问题