Omar Alaa Omar Alaa - 1 month ago 9
C# Question

Access inner class variables

How can I access members of an inner class?
For example.

class A
{
class B
{
public int X;
}
}

class C
{
// any possible way to summon int x here ?
}


What I want to do is summon the integer X inside of Class C. How can I do this?
Is the only way is this?

class A
{

}


class B
{
public int X;
}

class C
{
//summonning int x here
}

Answer

make the inner class public and some more reading https://msdn.microsoft.com/en-us/library/ms173120.aspx

public class A
{
        public Class B
        { 
          public int X;
        }
 }