---
title: "How to update Current object instance."  
description: "How to update Current object instance."  
author: "James Smith"  
published: 2011-04-16  
updated: 2011-04-16  
canonical: https://www.mindstick.com/forum/221/how-to-update-current-object-instance  
category: "c#"  
tags: ["c#"]  
reading_time: 2 minutes  

---

# How to update Current object instance.

Hello dear,

I have a method that [populate](https://www.mindstick.com/blog/60/populate-records-in-second-listbox-according-to-the-selection-in-first-list-box) my [class](https://www.mindstick.com/blog/165/generic-class-in-c-sharp) by loading an xml

```
public class Sample{          public void loadXML(string xmlFilePath)          {                 Sample smp=new Sample();                 smp=(Sample)s.Desserialize(reafer);   //Deserilize and populate my object from an xml file.                 return;          }}
```

[Now](https://yourviews.mindstick.com/view/81402/it-s-liberals-vs-progressives-in-us-politics-now) I just want to call this method from another class, so I simply have.\
\

```
MyClass testObj = new MyClass();
testObj.LoadXML("myFile.xml");
testObj --> is EMPTY after the function returns...
```

Here is my [question](https://www.mindstick.com/blog/23175/how-to-solve-neet-question-paper-in-less-time):

How can I make my current [instance](https://www.mindstick.com/forum/155658/testing-connection-to-cloud-sql-instance-with-a-mysql-client-from-vm-instance) (testObj) filled with the [data](https://www.mindstick.com/articles/13050/salesforce-aiming-to-dominate-predictive-analytics-with-data-science)... without having to RETURN an object from my method ? (I want my [method to return](https://www.mindstick.com/forum/55125/how-to-create-generic-method-to-return-multiple-list-in-c-sharp) void)

I want it to work similarly to the [NET](https://www.mindstick.com/articles/23172/login-mywifiext-net-and-setup-your-extender-by-the-advice-of-an-expert) XmlDocument class:

```
XmlDocument doc = new XmlDocument();doc.Load(..) //doc is filled with data
```

How can I do the same thing? Dows Anybody know how to do this?

Thank you very much in [advance](https://www.mindstick.com/blog/33258/jee-mains-and-jee-advance-exams) for any help

## Replies

### Reply by Anonymous User

We can use it following manner

\

```
public class SampleClass
{

 private int _myMember;

 public int MyMember

 {

  //get and set goes here

 }

 public void LoadXML(string xmlFilePath)

 {

  SampleClass myObj = new SampleClass();

  myObj = SampleClasss.Deserialize(reader);

  this.MyMember = myObj .MyMeber

  return;

 }

}
```


---

Original Source: https://www.mindstick.com/forum/221/how-to-update-current-object-instance

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
