Main.cs
using
System;
class
Program {
-
public
static
int
Main() {
-
int
[] ara =
new
int
[3] {10, 20, 30};
-
int
res1 = 0;
-
for
(
int
i=0; i<ara.Length; i++) {
-
res1+=ara[i];
-
}
-
Console.WriteLine(res1);
-
int
res2 = 0;
-
foreach
(var i
in
ara) {
-
res2+=i;
-
}
-
Console.WriteLine(res2);
-
Console.ReadKey();
-
return
0;
-
}
}
using
System;
class
Program {
-
public
static
int
Main() {
-
int
[] ara =
new
int
[3] {10, 20, 30};
-
int
res1 = 0;
-
for
(
int
i=0; i<ara.Length; i++) {
-
res1+=ara[i];
-
}
-
Console.WriteLine(res1);
-
int
res2 = 0;
-
foreach
(var i
in
ara) {
-
res2+=i;
-
}
-
Console.WriteLine(res2);
-
Console.ReadKey();
-
return
0;
-
}
}
60
60
60