this blog contains information for .net and sql stuffs. You can find various tips and tricks to overcome problem you may be facing in ...

Tuesday, May 1, 2012

Do not serialize public property or field in a class

There could be some situation where one have some properties and fields defined in the class. Most of time property are exposed as public and they can be easily accessed by object of class.

During the data transfer serialization of objects happens and at that time we have all the public fields and property contained in the class.

Some situation has special needs to prevent serializing public property or fields. Below code snippent shows how to handle such situation.

        public bool IsActive
            get { return this.mIsActive; }
            set { this.mIsActive = value; }

Have happy coding!!

No comments: