Passing parameters to methods : Function Parameters « Language Basics « C# / C Sharp






Passing parameters to methods

 

using System;

class ParameterTest {
    static void SomeFunction(int[] ints, int i) {
        ints[0] = 100;
        i = 100;
    }

    public static void Main() {
        int i = 0;
        int[] ints = { 0, 1, 2, 4, 8 };

        Console.WriteLine("i = " + i);
        Console.WriteLine("ints[0] = " + ints[0]);
        Console.WriteLine("Calling SomeFunction...");

        SomeFunction(ints, i);
        Console.WriteLine("i = " + i);
    }
}

 








Related examples in the same category

1.Reference, output and value parameters.
2.creates instances of a value and a reference type
3.Pass valuel by pointer
4.ref pointer parameter
5.Arrays as Function Returns and Parameters
6.Use ref to mark an object parameter
7.Use out to mark an object parameter
8.Pass integer by reference