I am just a learner in .net . I am presently learning serialization in .net by my own.Just a quick question.
When we serialize any class using serializable attribute, the whole class gets serialized right?
Consider this code
Expand|Select|Wrap|Line Numbers
- [Serializable]
- public class Store
- {
- private int sCount;
- public int stockCount
- {
- get { return sCount; }
- set { sCount = value; }
- }
- [NonSerialized]public int temp;
- public string storeName = "My Local Store";
- public Store()
- {
- stockCount = 0;
- }
- }
But when I serialized and then DeSerialized this class into Store object, it is showing the value of temp =0; How did it get back the temp variable as we omitted the serialization of temp variable?
Or will it save the temp variable in file and omits the value or totally omits the temp variable?
Can any one explain what exactly happens to the temp variable?
Note: Source code is also available at http://www.csharpfriends.com/Article...x?articleID=94 I was following this example when displaying the content, I used Console.WriteLine at the end of program in main
Any help is much appreciated. Thanks heaps in advance.