Click here to Skip to main content
15,914,312 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a case as follows
class nurses
{
...
...
}
class shifts
{
nurses _nurses;
shifts(nurses _nurses)
{
this._nurses=_nurses;// here the reference of nurses is assigned not the value.
}
...
...
}
main()
{
var ns=new nurses();
var shfts= new shifts(ns);//I want to pass the ns as copy so the value of ns is not changed after shifts make changes on its copy.


}


Please suggest some quick solution. It is confusing to me.
Thank you
Posted
Updated 17-Jun-11 5:15am
v2

You can either define nurses as a struct, making it a value type:

http://msdn.microsoft.com/en-us/library/ah19swz4%28v=vs.71%29.aspx[^]

or you can implement IClonable on nurses to create a copy:

http://msdn.microsoft.com/en-us/library/system.icloneable.aspx[^]
 
Share this answer
 
Comments
J imran 17-Jun-11 11:21am    
Thank you so much.you saved my time...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900