sha*_*pan 2 c# arrays generics collections attributes
我正在使用.NET 2.0我有一个很大的字符串数组.我想检查数组中是否存在特定字符串,我不确定,是否优化了以下代码或者我需要对其进行更优化.请指导.
string []test_arr= new string[]{"key1","key2","key3"};
Boolean testCondition = (new List<string>(test_arr)).Contains("key3");
Run Code Online (Sandbox Code Playgroud)
我也想了解更多
是否有任何好的参考或书籍,有人已经参考,然后帮助我!
string []test_arr= new string[]{"key1","key2","key3"};
bool testCondition = Array.Exists
(
test_arr,
delegate(string s) { return s == "key3";}
);
Run Code Online (Sandbox Code Playgroud)