I'm learning how to program using c#. I'm really new to this. My question is I'm trying to create an array that shows 10 numbers. I want my code to check which numbers below 10 are divisible for 3 or 5 and sum the total. I've tried to use the .Sum() function but says int doesn't contain a definition for Sum. I've put using System.Linq on my program. Does anyone have an idea how to make this sum happens?
{
int[] numbers = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
int sum = 1 + 2;
foreach (int n in numbers)
{
if (n % 3 == 0 || n % 5 == 0)
{
int total = n.Sum();
Console.WriteLine(total);
}
else
{
Console.WriteLine("not divisible");
}
}`
Sum()is a part of), then you may want, instead of the loop, a call toWhere(). But it's not entirely clear what the final goal is here, nor what kind of help would be best for this apparent homework assignment.