How to find a sub-list of two consecutive items in a list using Linq

前端 未结 5 1658
长发绾君心
长发绾君心 2021-01-26 19:56

Suppose that we have a list of strings like

\"A\", \"B\", \"C\", \"D\", \"E\", \"F\"

Now I\'d like to search for a sub-list of

5条回答
  •  再見小時候
    2021-01-26 20:53

    Not a good general or efficient answer, but concise - as it is a list of strings / characters, you could do a simple string.Join() and check for the substring:

    int p = string.Join("", list).IndexOf("DE");
    

提交回复
热议问题