Harmath Bálint
Harmath Bálint

Reputation: 21

Get Parent From Child Scope

How can I get/set an Object from a parent from a child's scope?

class Parent
{
    var pictureBox1 = new PictureBox();
       ...
    class  Child
    {
        List<string, PictureBox> list;

        Child()
        {
            list.Add("000", /*Here I want to get the Parent elements PictureBox1 instant*/);
               etc.
            // I also set it later
            list[0].Item2.Text = "newPicture";
        }
    }
}

So this way I implement these things, and my question is how can I get from Child scope to the Parent.pictureBox1 element.

Upvotes: 0

Views: 509

Answers (1)

JNK
JNK

Reputation: 836

This is not possible in C#.

You need to pass the pictureBox to the Child class. See this link: C# nested classes are like C++ nested classes, not Java inner classes

Upvotes: 1

Related Questions