Fastest way to compare a string with an array of strings in C#2.0

后端 未结 4 1475
南旧
南旧 2020-12-30 04:07

What is the fastest way to compare a string with an array of strings in C#2.0

4条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-30 04:27

    You mean to see if the string is in the array? I can't remember if arrays support the .Contains() method, so if not, create a List< string >, add your array to the list via AddRange(), then call list.Contains({string to compare}). Will return a boolean value indicating whether or not the string is in the array.

提交回复
热议问题