Example #1
0
    public static void Main()
    {
        int   intValue   = 10;
        float floatValue = 10.0F;

        MyClass.HandleNumber(intValue);
        MyClass.HandleNumber(floatValue);

        Console.WriteLine("MyConst={0}, MyStringConst={1}",
                          MyClass.MY_CONST, MyClass.MY_STRING_CONST);

        int i = 10;

        PassByReference.AlterInteger(ref i);
        Console.WriteLine("Finally : {0}", i);

        int [] myArray = new int [] { 401, 301, 20, 30, 40 };
        PassByReference.DumpArray("Before AlterArray:", myArray);
        PassByReference.AlterArray(myArray);
        PassByReference.DumpArray("After AlterArray:", myArray);

        myArray[0] = 1000;
        PassByReference.DumpArray("Before AlterArrayRef:", myArray);
        PassByReference.AlterArrayRef(ref myArray);
        PassByReference.DumpArray("After AlterArrayRef:", myArray);

        PassByReference.DumpArray("Before AllocArray:", myArray);
        PassByReference.AllocArray(myArray);
        PassByReference.DumpArray("After AllocArray:", myArray);

        myArray[0] = 1000;
        PassByReference.DumpArray("Before AllocArrayRef:", myArray);
        PassByReference.AllocArrayRef(ref myArray);
        PassByReference.DumpArray("After AllocArrayRef:", myArray);
    }
Example #2
0
 static void Main(string[] args)
 {
     PassByValue.Run();
     PassByReference.Run();
 }