title: How to assign Values to a Property of an object using Task in C#
body: <p>I'm Having a Model Class, each property is mapped with a Model Class.</p>
  
  <p>Consider the Model Class "<strong><code>Contact</code></strong>"</p>
  
  <pre><code>public class Contact
  {
      public Profile profileInfo { get; set; }
      public bool isActive { get; set; }
  }
  
  public class Profile
  {
      public string FirstName { get; set; }
      public string LastName { get; set; }
  }
  </code></pre>
  
  <p>Task related C# Code is</p>
  
  <pre><code>public void MapContact(ref Contact contactInfo)    
  {
      List&lt;Task&gt; taskList = new List&lt;Task&gt;();
  
      taskList.Add(Task.Factory.StartNew(() =&gt;
      {
          contactInfo.profileInfo = client.GetProfileInfo(1);
      }));
  
      Task.WaitAll(taskList.ToArray());
  }
  </code></pre>
  
  <p>I'm getting the Compile Time error "<em>Cannot use ref or out parameter 'contactInfo' inside an anonymous method, lambda expression, or query expression</em>" in the following statement</p>
  
  <pre><code>contactInfo.profileInfo = client.GetProfileInfo(1);
  </code></pre>
  
  <p>Kindly assist me how to use Task efficiently without any Compile-Time Error.</p>
  
  <p>Here with I attached the Screenshot</p>
  
  <p><a href="https://i.stack.imgur.com/oG9gS.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oG9gS.jpg" alt="enter image description here"></a></p>