Hello...
I have an object which has a nested object which need to look at the
parent to return a value
about it. Basically as below but when I put the ref method parameter
to construct the nested class, I get the error message about "this"
(the parent being readonly).
When I leave out the ref keyword things compile, but I want to make
sure I pass by reference so I can save memory. As you can see the
parent is passed but not modified by the nest class. Any ideas?
namespace test
{
public class User
{
private Status _Status;
private string _Level
public User()
{
this._Status = new Status(ref this);
}
public string Level
{
get { return _Level;}
set {_Level = value;}
}
public class Status
{
private User _User;
public Status(ref User usr)
{
_User = usr;
}
public string UserCurrentLevel
{
get { return _User.Level;}
}
}
}
}