Witam,
Poniżej znajduje się kod który napisałem. W pierwszej Metodzie chciałem, aby użytkownik wpisał ilość elementów swojej tablicy oraz później jej elementy. W drugiej natomiast nastąpiłoby sumowanie elementów podanej tablicy.
static int PobierzEle(int[] t)
{
Console.WriteLine("Podaj Elementy tablicy");
int x = Convert.ToInt32(Console.ReadLine());
int[] y = new int[x];
for (int i = 0; i < x; i++)
{
Console.WriteLine("Podaj Element {0}", y[i]);
y[i] = Convert.ToInt32(Console.ReadLine());
}
return x;
}
static int[] SumaTab(int[] t)
{
int[] A = new int[PobierzEle(t)];
int wynik = 0;
for (int i = 0; i < A.Length; i++)
{
wynik = wynik + A[i];
}
Console.WriteLine("Suma elementów twojej tablicy to: {0}",wynik);
return A;
}
static void Main(string[] args)
{
int[] d = new int[SumaTab(t)];
SumaTab(PobierzEle);
Console.ReadKey();
}
Mój problem polega na tym, że nie wiem jak sformułować linie kodu, aby wywołać te dwie metody w Main'ie.