string array.Contains?

前端 未结 10 1432
无人及你
无人及你 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 03:50

    I have found an elegant answer at the page here http://www.dotnettoad.com/index.php?/archives/10-Array.Contains.html. What you have to do in .NET 2.0 is to cast to IList and call Contains method.

    (IList mystrings).Contains(test);
    

提交回复
热议问题