Answer to Question #28119 in C# for kumar

Question #28119
Subject: C# - serialize only those properties whcich are specified [xmlattribute(“NAME”)] without changing the original class


[Serializable]
public class MyClass
{
[XmlElement("Company")]
public string Company { get; set; }

[XmlElement("Amount")]
public decimal Amount { get; set; }

public int companyid { get; set; }
}


now i want to serilize only thoese which are specified with [XmlElement], companyid not to be serilized.

so what i can do.
1
Expert's answer
2013-04-10T11:42:02-0400
[NonSerialized()]

[Serializable]
public class MyClass
{
[XmlElement("Company")]
public string Company { get; set; }

[XmlElement("Amount")]
public decimal Amount { get; set; }

[NonSerialized()]
public int companyid { get; set; }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS