Returning the existence of a key in a dict by searching key substring

前端 未结 6 772
借酒劲吻你
借酒劲吻你 2020-12-20 09:08

I have a dictionary of string people (key) and string addresses (value). I want to have an if statement that returns true if any key in my dictionary contains the substring

6条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-20 10:04

    if(dict.Keys.Any(k=>k.Contains("anders")))
    {
        //do stuff
    }
    

提交回复
热议问题