G
Guest
I have a data model with this structure:
Class
PropertyA
PropertyB
Collection
Class
Property1
Property2
The outermost class has a handler that correctly deals with events fired by
properties within it (ie. PropertyA, PropertyB, etc.).
The innermost class has a similar handler for dealing with its own properties.
What I want to do is have the innermost handler pass its data to the
outermost handler. But I can't seem to accomplish this and am not sure why.
Here's the code that I thought would work:
public class _Question // outermost class
{
private _Choices instanceChoices = new _Choices(this);
public _Choices Choices
{
get
{
return instanceChoices;
}
}
}
The "_Choices" constructor is setup to receive an instance of "_Choice"
being passed to it but the compiler rejects the "this" that you see above.
It reports this error: "Keyword this is not available in the current context"
But I don't understand why. Can someone explain?
Class
PropertyA
PropertyB
Collection
Class
Property1
Property2
The outermost class has a handler that correctly deals with events fired by
properties within it (ie. PropertyA, PropertyB, etc.).
The innermost class has a similar handler for dealing with its own properties.
What I want to do is have the innermost handler pass its data to the
outermost handler. But I can't seem to accomplish this and am not sure why.
Here's the code that I thought would work:
public class _Question // outermost class
{
private _Choices instanceChoices = new _Choices(this);
public _Choices Choices
{
get
{
return instanceChoices;
}
}
}
The "_Choices" constructor is setup to receive an instance of "_Choice"
being passed to it but the compiler rejects the "this" that you see above.
It reports this error: "Keyword this is not available in the current context"
But I don't understand why. Can someone explain?