Why is this code throwing an InvalidOperationException?

前端 未结 2 2078
孤独总比滥情好
孤独总比滥情好 2021-02-14 16:06

I think that my code should make the ViewBag.test property equal to \"No Match\", but instead it throws an InvalidOperationException.

2条回答
  •  后悔当初
    2021-02-14 16:58

    Give this a shot:

    bool hasMatch = str.Split(',').Any(x => x.Equals(another));
    
    ViewBag.test = hasMatch ? "Match" : "No Match";
    

提交回复
热议问题