XElement.Descendants()使其不区分大小写 [英] XElement.Descendants () make it case-insensitive

查看:285
本文介绍了XElement.Descendants()使其不区分大小写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

XElement.Descendants()方法接受要查找的元素的名称.

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

但是它区分大小写,有什么办法可以使其不区分大小写

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

推荐答案

您可以使用此

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

这篇关于XElement.Descendants()使其不区分大小写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆