Main.cs
using
System;
class
One {
-
public
int
Sum(
int
[] arg) {
-
int
res = 0;
-
foreach
(var i
in
arg) {
-
res+=i;
-
}
-
return
res;
-
}
}
class
Program {
-
public
static
int
Main() {
-
int
[] ara =
new
int
[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
-
foreach
(var i
in
ara) {
-
Console.Write(
"{0} "
, i);
-
}
-
Console.WriteLine();
-
One O =
new
One();
-
Console.WriteLine(
"сумма элементов : {0}"
, O.Sum(ara));
-
Console.WriteLine();
-
Console.ReadKey();
-
return
0;
-
}
}
using
System;
class
One {
-
public
int
Sum(
int
[] arg) {
-
int
res = 0;
-
foreach
(var i
in
arg) {
-
res+=i;
-
}
-
return
res;
-
}
}
class
Program {
-
public
static
int
Main() {
-
int
[] ara =
new
int
[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
-
foreach
(var i
in
ara) {
-
Console.Write(
"{0} "
, i);
-
}
-
Console.WriteLine();
-
One O =
new
One();
-
Console.WriteLine(
"сумма элементов : {0}"
, O.Sum(ara));
-
Console.WriteLine();
-
Console.ReadKey();
-
return
0;
-
}
}
1 2 3 4 5 6 7 8 9 10
сумма элементов : 55
сумма элементов : 55