我有以下代码:
p.tel.FirstOrDefault(t => t.teltype == "mobile").ToString()
<person>
<name>Donald Duck</name>
<tel teltype="voice" />
<tel teltype="mobile">01000000</tel>
</person>
xml的c#类如下:
[System.Xml.Serialization.XmlElementAttribute("tel")]
public enterprisePersonTel[] tel {
get {
return this.telField;
}
set {
this.telField = value;
}
}
我的代码返回:enterprisePersonTel
这不起作用
p.tel.FirstOrDefault(t => t.teltype == "mobile").Value
如何获取实际电话号码?
答案 0 :(得分:0)
该属性的类未正确生成
public partial class enterprisePersonTel
{
private string teltypeField;
private string valueField;
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public string teltype
{
get
{
return this.teltypeField;
}
set
{
this.teltypeField = value;
}
}
/// <remarks/>
**[System.Xml.Serialization.XmlTextAttribute()]
public string Value
{
get
{
return this.valueField;
}
set
{
this.valueField = value;
}
}**
} 在Visual Studio中将粘贴用作类时,缺少文本的**部分。