60 477
Assignments Done
98,1%
Successfully Done
In April 2018

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.
Expert's answer
[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

Submit
Privacy policy Terms and Conditions