title: How do I retrieve data from a list<> containing class objects
body: <p>I want to retrieve data from a list I created that contains class objects via a foreach but I'm not able to. 
  Can somebody please tell me what's missing in my code? </p>
  
  <p>I have a class Recipes.cs that contains the following code: 
      public class Recipe
      {</p>
  
  <pre><code>    string _oveskrift;
      int _recipe_id;
      string _opskrift;
      int _kcal;
  
      public Recipe(string overskrift, int recipe_id, string opskrift,int kcal)
      {
          _oveskrift = overskrift;
          _recipe_id = recipe_id;
          _opskrift = opskrift;
          _kcal = kcal;
      }
  
  }
  
  public class Recipes
  {
      public List&lt;Recipe&gt; CreateRecipeList()
      {
          Recipe opskrift1 = new Recipe("Cornflakes med Chili",1,"4 kg cornflakes bages", 420);
          Recipe opskrift2 = new Recipe("Oksemørbrad",2,"Oksemørbrad steges i baconfedt", 680);
          Recipe opskrift3 = new Recipe("Tun i vand",3,"Dåsen åbnes og tunen spises", 120);
  
          List&lt;Recipe&gt; Recipelist = new List&lt;Recipe&gt;(); 
  
          Recipelist.Add(opskrift1);
          Recipelist.Add(opskrift2);
          Recipelist.Add(opskrift3);
  
          return Recipelist;
      }
  }
  </code></pre>
  
  <p>I call CreateRecipeList() from another class calculator.cs and the code looks like this: </p>
  
  <pre><code>private int FindRecipes()
  {
      List&lt;Recipe&gt; Rlist = new List&lt;Recipe&gt;();
  
      // CREATE THE CLASS AND ADD DATA TO THE LIST 
      Recipes r = new Recipes();
      Rlist = r.CreateRecipeList();
  
      int test = 0; // used only for test purposes          
  
      foreach(var rec in Rlist)
      {
          rec.????
          test++;
      }
  
      return test;
  }
  </code></pre>
  
  <p>I would presume that I should be able to dot my way into rec."the class object name"."the value"<br>
  But nothing happens!. 
  All I get is the option to rec.Equals, rec.GetHashcod ect. which is clearly wrong. </p>
  
  <p>For the record I have also tried:</p>
  
  <pre><code>foreach(Recipe rec in Rlist)
  {
      rec.????
      test++;
  }
  </code></pre>
  
  <p>But that doesn't work either. 
  The Int test are only there for test purposes.. and it return 3.. so the list does contain the correct information. </p>