title: C#: Error-Cannot implicitly convert type 'int' to 'System.Collections.Generic.IEnumerable<double>'
body: <p>I am trying to override the median value of a object EducationData, The model definition is as follows,</p>
  
  <pre><code>// EducationData model
  [DataMember(Name = "DegreeConferred", Order = 1)]
  public int DegreeConferred { get; set; }
  [DataMember(Name = "NoOfInstitutions", Order = 3)]
  public int NoOfInstitutions { get; set; }
  [DataMember(Name = "Mean", Order = 6)]
  public int Mean { get; set; }
  [DataMember(Name = "Median", Order = 7)]
  public IEnumerable&lt;double&gt; Median { get; set; }
  </code></pre>
  
  <p>CachedData is of type var, contains the ES query results of the education details as in the picture attached. </p>
  
  <p><a href="https://i.stack.imgur.com/YUEc3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YUEc3.png" alt="enter image description here"></a></p>
  
  <p>I have to override that median value with some alterations. Code segment I tried is as follows.</p>
  
  <pre><code>var resultData = cachedData.ToArray();
  resultData[0].Mean = resultData[0].DegreeConferred / resultData[0].NoOfInstitutions; // calculated mean with no error
  var updatedMedian = 7; // say for sample, because there is a need to override this queried value with some modification.
  resultData[0].Median = updatedMedian; // Error line: Cannot implicitly convert type 'int' to 'System.Collections.Generic.IEnumerable&lt;double&gt;'
  </code></pre>
  
  <p>Please Note: Changing the property to int in the model will affect the implementation in further places. So it will be better to do casting here.</p>
  
  <p>I tried with ReSharper suggestion, like, but nothing works</p>
  
  <pre><code>resultData[0].Median = Convert.ToDouble(updatedMedian);
  resultData[0].Median = IEnumerable&lt;double&gt;updatedMedian;
  Also changing the property of updatedMedian will affect the calculation steps.
  </code></pre>
  
  <p>I have also tried some of the suggestion of SO as,</p>
  
  <ol>
  <li><a href="https://stackoverflow.com/questions/1487072/linq-cannot-implicitly-convert-type-system-collections-generic-ienumerableint">LINQ: Cannot implicitly convert type &#39;System.Collections.Generic.IEnumerable&lt;int&gt;&#39; to &#39;int&#39;</a></li>
  <li><a href="https://stackoverflow.com/questions/16512316/linq-query-cannot-convert-type-ienumerablestring-to-string-changing-tostrin">Linq Query : Cannot convert type IEnumerable&lt;string&gt; to string changing .ToString() to (string)</a></li>
  <li><a href="https://stackoverflow.com/questions/23809195/cannot-implicitly-convert-type-system-collections-generic-ienumerable">Cannot implicitly convert type &#39;System.Collections.Generic.IEnumerable</a></li>
  </ol>
  
  <p>I am struggling with this for past one and half days. Any suggestion would be very helpful.</p>