Using LINQ extension method syntax on a MatchCollection

前端 未结 6 1260
逝去的感伤
逝去的感伤 2020-12-13 01:20

I have the following code:

MatchCollection matches = myRegEx.Matches(content);

bool result = (from Match m in matches
               where m.Groups["nam         


        
6条回答
  •  情书的邮戳
    2020-12-13 02:05

    Try this:

    var matches = myRegEx.Matches(content).Cast();
    

    For reference, please see Enumerable.Cast:

    Converts the elements of an IEnumerable to the specified type.

    Basically it's one way of turning an IEnumerable into an IEnumerable.

提交回复
热议问题