Example #1
0
        static void Main(string[] args)
        {
            ClassA myObject = new ClassA();

            Console.WriteLine($"myObject.State = {myObject.State}");
            ClassA.ClassB myOtherObject = new ClassA.ClassB();
            myOtherObject.SetPrivateState(myObject, 999);
            Console.WriteLine($"myObject.State = {myObject.State}");
        }
Example #2
0
 static void Main(string[] args)
 {
     ClassA myObject = new ClassA();
      Console.WriteLine("myObject.State = {0}", myObject.State);
      ClassA.ClassB myOtherObject = new ClassA.ClassB();
      myOtherObject.SetPrivateState(myObject, 999);
      Console.WriteLine("myObject.State = {0}", myObject.State);
      Console.ReadKey();
 }
Example #3
0
        static void Main(string[] args)
        {
            var myObject = new ClassA();

            WriteLine($"myObject.State = {myObject.State}");
            var myOtherObject = new ClassA.ClassB();

            myOtherObject.SetPrivateState(myObject, 999);
            WriteLine($"myObject.State = {myObject.State}");
            ReadKey();
        }
Example #4
0
        static void Main(string[] args)
        {
            ClassA myObject = new ClassA();

            WriteLine($"myObject.State = {myObject.State}");

            // Create an instance of the nested class, and use it to set the read-only State
            // property of the outer class. Note the hierarchical syntax required to define
            // and instantiate the nested class.
            ClassA.ClassB myOtherObject = new ClassA.ClassB();
            myOtherObject.SetPrivateState(myObject, 999);
            WriteLine($"myObject.State = {myObject.State}");
            ReadKey();
        }
Example #5
0
        static void Main(string[] args)
        {
            // Create main class, show current val of state
            ClassA myObject = new ClassA();

            WriteLine($"myObject.State = {myObject.State}");

            // Create the subclass, call its method and pass the main class
            ClassA.ClassB myOtherObject = new ClassA.ClassB(); // Interessant dat een subclass van een object toegang heeft tot de private members van een ander object
            myOtherObject.SetPrivateState(myObject, 999);

            // Show the current val of state
            WriteLine($"myObject.State = {myObject.State}");
        }