mahesh gupta

mahesh gupta

  • NA
  • 14
  • 180.6k

Can anyone please clarify this basic query

Mar 25 2011 2:55 PM
Hi all Im very new to .net. I have opted this site to learn. Now when Im going through the tutorials i made small code snippet for practice. 
class myclass
{
        int no;
        string st;
}
main()
{
        myclass temp = new myclass();
        myclass ab = new myclass():
        temp.no = 1;
        temp = ab;
        temp.no = 2;
        ab.no =3;

        After here no matter how changes i make to ab.. itz effecting temp also.. I understand it is taking as a reference. But please clarify me that if i want only contents to be copied what should I do.. Please dont mind I know Im asking very basic silly doubt.. Understand my prblem becoz I have come from C background.. Im getting hard to understand C#.


}

Answers (4)