title: How can I enumerate through a HashSet?
body: <p>I have an object defined like this:</p>
  
  <pre><code>public class Problem
  {
      public Problem()
      {
          this.Questions = new HashSet&lt;Question&gt;();
      }
  
      public string Answer { get; set; }
  }
  </code></pre>
  
  <p>I need to check each of the Questions in the object <code>problem</code> and manipulate some data.  Here's what I have tried:</p>
  
  <pre><code>foreach (Question question in problem)
  {
      if (question.AssignedTo == null)
      {
          question.QuestionStatusId = 6;
      }
      else
      {
          question.AssignedDate = DateTime.UtcNow;
          question.QuestionStatusId = 5;
      }
  }
  </code></pre>
  
  <p>But this does not work. I get an error message saying:</p>
  
  <blockquote>
    <p>Severity  Code    Description Project File    Line
    Error   CS1579  foreach statement cannot operate on variables of type 'Entities.Models.Core.Problem' because 
    'Entities.Models.Core.Problem' does not contain a public definition for 'GetEnumerator' </p>
  </blockquote>
  
  <p>Is there another way that I can do this? Note that the reason I used <code>new HashSet&lt;Question&gt;</code> was because I was told this is the way to do this if there are unique questions.</p>