I am trying to write a C# function to determine the maximum value in an array and to pass it by reference.
It is my first time programming in C#, but it's really bugging me that I don't to seem to be able to assign it correctly in the main.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication4
{
    class Program
    {
        static void Maxim(int n, ref int maxim, params int[] v) {
            int i,  max=v[0];
            for (i = 0; i < n; i++) {
                if (v[i] >  max)  max = v[i];
            }
        }
        static void Main()
        {
            int[] vector = new int[10];
            int n, i;
            int maximul;
            Console.WriteLine("Introduceti numarul de elemente: ");
            n = Int32.Parse(Console.ReadLine());
            Console.WriteLine("Valoarea introdusa: {0}", n);
            for (i = 0; i < n; i++) {
                vector[i] = Int32.Parse(Console.ReadLine());
            }
            Console.WriteLine("Elementele introduse sunt: ");
            for (i = 0; i < n; i++) {
                Console.WriteLine("Elementul {0}:  {1}", i + 1, vector[i]);
            }
            Maxim(n, ref maximul, vector);
            Console.WriteLine("Maximul din vector: {0}",  maximul);
            Console.ReadLine();
        }
    }
}
It returns me the following error: Use of unassigned local variable.
 
     
     
     
    