title: LINQ: Select single value from object array, by id
body: <p>Take the following example class:</p>
  
  <pre><code>public class Questions
  {
      public Int32 QuestionId { get; set; }
      public String Question { get; set; }
      public String Answer { get; set; }
  }
  </code></pre>
  
  <p>And the following array:</p>
  
  <pre><code>var questionArray = new Questions[]
  {
      new Questions {QuestionId = 1, Question = "How old are you?", Answer = "32"},
      new Questions {QuestionId = 2, Question = "What is your name?", Answer = "John"},
      new Questions {QuestionId = 3, Question = "How tall are you?", Answer = "6'"}
  };
  </code></pre>
  
  <p>Using LINQ, I want to get the <code>Answer</code> for a specified <code>QuestionId</code>. For example, if I gave <code>QuestionId</code> 2, the result would be 'John'.</p>
  
  <p>I want to be able to pull out the answer to a specific question to populate a separate DTO. ie:</p>
  
  <pre><code>var person = new PersonDto {Name = &lt;single line LINQ goes here&gt;};
  </code></pre>
  
  <p>So far I have only managed to get an answer using the following:</p>
  
  <pre><code>foreach (var q in questionArray.Where(q =&gt; q.QuestionId == 2))
  {
      var answer = q.Answer;
  }
  </code></pre>
  
  <p>Is this possible in 1 line of code?</p>