Using newtonsoft json you can achieve deep cloning easily.
Sample
Now if you update the emp1 data it reflect the emp object too.
for avoid this you can use object cloning.
var serialized = JsonConvert.SerializeObject(AnyObject); var deserializedObject JsonConvert.DeserializeObject<TypeOfObject>(serialized);
Sample
List<Employee> emp= new List<Employee>(); List<Employee> emp1 = new List<Employee>(); emp1=emp;
Now if you update the emp1 data it reflect the emp object too.
for avoid this you can use object cloning.
var serialized = JsonConvert.SerializeObject(emp); var deserializedObject = JsonConvert.DeserializeObject<List<Employee>>(serialized);
Top 60 Xamarin Blog
No comments:
Post a Comment