Ejemplo n.º 1
0
        //Entry point to the program
        static void Main(string[] args)
        {
            //This is an example of 2 ExampleObjects being created
            ExampleClass exampleObject  = new ExampleClass();
            ExampleClass exampleObject2 = new ExampleClass();

            //This is an example of an object's public method PrintState() being called
            exampleObject.PrintState();

            //This is an example of an object state being changed
            exampleObject.SetExampleField("ExampleObject's state changed!");
            exampleObject.PrintState();

            //This is an example of an object state being changed by a global function
            ExampleClass.ExampleGlobalFunction(exampleObject);
            exampleObject.PrintState();

            //Example of accessing the global varible of ExampleClass.
            Console.WriteLine("Number of ExampleClass instances: " + ExampleClass.InstanceCount);
        }
Ejemplo n.º 2
0
 /*
  * Example of global function for ExampleClass.
  * Static functions work like a static variables as they work outside of object space.
  */
 public static void ExampleGlobalFunction(ExampleClass exampleObject)
 {
     exampleObject.SetExampleField("ExampleObject's state changed by ExampleClass's global function!");
 }