I'm trying to get the following bit of code to print out the "sum" to the console, it compiles fine and everything but never prints out the sum. Can someone give me a hint please? Thanks.
class Program
{
static void Main(string[] args)
{
// Not sure how to call "ArraySum" from here.
}
public void ArraySum()
{
int[] arr = { 1, 2, 3, 4, 5 };
int sum = 0;
foreach (int x in arr)
{
sum += x;
}
Console.WriteLine(sum);
}
EDIT: Sorry for not posting the whole code, but yeah. Basically I'm not sure how to call the method from main and have it print out the sum.