8,497
社区成员
发帖
与我相关
我的任务
分享
int? id = xelIEnumerable.SingleOrDefault((c) =>
{
if (c.Attribute("name").Value == name)
{ return int.Parse(c.Attribute("id").Value); }
});
int? id = xelIEnumerable.where(c=>c.Attribute("name").Value == name).select(c=>int.Parse(c.Attribute("id").Value).SingleOrDefault()
var xe = xelIEnumerable.SingleOrDefault( c=> c.Attribute("name").Value == name );
int? id = null;
if( xe != null ){
id = int.Parse(xe.Attribute("id").Value);
}