title: Static Method That Finds Sum of All Even Numbers in a List
body: <p>Beginner at C#. I'm familiar with Python, and in Python, (I think) you would do something like this: </p>
  
  <pre><code>myList = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
  
  def SumOfEvens(myList):
  
      #Initialize the results variable.
      result = 0  
  
      #Loop through each element of the list.
      for i in myList:  
  
      #Test for even numbers.
          if not i % 2:  
          result += i
  
  return(result)
  
  print SumOfEvens(myList)
  30
  </code></pre>
  
  <p>I'm trying to recreate this in C#, except that I need to write a static method and then call that method on a list within <code>Main</code></p>
  
  <p>So far this is what I have: </p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  
  namespace Strings
  {
  class Program
      {
          static void SumofEvens(string[] args)
          {
          //initialize results variable
          int result = 0
  
          //check if the number is even. If it's even, add it.
          foreach (int i in l)
              if (i % 2 == 0)
              {
                  int result += i
              }
  
          }
          static void Main(string[] args)
          {
              l = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
              return SumofEvens(l);
          }
      }
  }
  </code></pre>
  
  <p>To start with, I don't know how to properly create the list <code>l</code> within main. Is the correct way to do it like this? </p>
  
  <p><code>int[] l = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]</code></p>
  
  <p>Then I need to write the result of <code>Main</code> to the console. Would that be</p>
  
  <pre><code>Console.WriteLine(Main);
  Console.ReadLine();
  </code></pre>
  
  <p>And where would it go at the very bottom of my code? Currently that just tells the Console to say "enter an integer". Thanks for any help. </p>