High performance “contains” search in list of strings in C#

前端 未结 7 1624
情话喂你
情话喂你 2020-12-05 07:54

I have a list of approx. 500,000 strings, each approx. 100 characters long. Given a search term, I want to identify all strings in the list that contain the search term. At

7条回答
  •  死守一世寂寞
    2020-12-05 08:30

    You should try to use Dictionary class. It's much faster than List because it's an indexed search.

    Dictionary ldapDocument = new Dictionary();
    //load your list here
    //Sample -> ldapDocument.Add("014548787","014548787");
    var match = ldapDocument.ContainsKey(stringToMatch);
    

提交回复
热议问题