0
如何將這兩個linq查詢重寫爲一個? .AncestorsAndSelf不支持null作爲元素名稱。linq AncestorsAndSelf使用null參數
if (ancestorElementName == null)
{
ancestorElements =
currentElement
.AncestorsAndSelf()
.Select(
.
.
.
);
}
else
{
ancestorElements =
currentElement
.AncestorsAndSelf(ancestorElementName)
.Select(
.
.
.
);
}
爲了澄清你想使用LINQ選擇指定的元素是否爲空時? – Pseudonym 2015-04-02 19:34:27