Why is this code throwing an InvalidOperationException?

前端 未结 2 1375
太阳男子
太阳男子 2021-02-14 16:08

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 17:01

    Give this a shot:

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

提交回复
热议问题