XElement.Descendants () make it case-insensitive

后端 未结 2 1354
长发绾君心
长发绾君心 2020-12-21 06:03

XElement.Descendants () method accepts name of element to be find.

But it is case-sensitive is there any way to make it case-insensitive

2条回答
  •  难免孤独
    2020-12-21 06:17

    You can use this:

    element.Descendants()
           .Where(x => string.Compare(x.Name, filter,
                                      StringComparison.OrdinalIgnoreCase) == 0);
    

提交回复
热议问题