7

I'm using System.Web.Script.Serialization.JavaScriptSerializer to serialize an object to JSON, but there are some fields within the object which don't need to be serialized. In java I would mark them with the 'transient' keyword. Is there an equivalent keyword or standard practice in C#?

T.D. Smith
  • 984
  • 2
  • 7
  • 22
  • Read this http://www.codeproject.com/Articles/4881/A-Comparative-Study-of-Java-and-C and search to transient in the web page. – Nikhil Agrawal Jun 03 '15 at 19:38

1 Answers1

13

Put [ScriptIgnore] attribute on the property and it will not be serialized.

See: ScriptIgnoreAttribute Class

Habib
  • 219,104
  • 29
  • 407
  • 436