> For the complete documentation index, see [llms.txt](https://raviram.gitbook.io/c-programing/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://raviram.gitbook.io/c-programing/oop-part-1/passing-arguments.md).

# Passing arguments

## Passing arguments

What is the output of the following code?

```csharp
using System;

class A
{
    public int x = 25;
}

class Program
{
    static void Main(string[] args)
    {
        int x = 25;
        f1(x);
        Console.WriteLine(x);

        int[] a = {25};
        f2(a);
        Console.WriteLine(a[0]);

        A obj = new A();
        f3(obj);
        Console.WriteLine(obj.x);
    }

    static void f1(int x)
    {
        x = x + 5;
    }

    static void f2(int[] x)
    {
        x[0] = x[0] + 5;
    }

    static void f3(A obj)
    {
        obj.x = obj.x + 5;
    }
}
```

{% hint style="info" %}
Primitive types are passed by **value** and non-primitive types are passed by **reference**!
{% endhint %}
