Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the C# Equivalent of java's transient keyword? [duplicate]

Tags:

c#

.net

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#?

like image 961
T.D. Smith Avatar asked Jun 03 '15 19:06

T.D. Smith


1 Answers

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

See: ScriptIgnoreAttribute Class

like image 54
Habib Avatar answered Oct 19 '22 05:10

Habib