title: how to assign value class within class property
body: <p>my recent post one developer provide me solution. create class but how to assign values this class.. please help me</p>
  
  <p>Create a class with required properties to be sent in request.
  //for example</p>
  
  <pre><code>   public class BookingInformation
      {
         public string booking_id { get; set; }
         public ToLocation to_location { get; set; }
         public string notes { get; set; }
      }
  
  
  
     public class ToLocation
   {
       public double latitude { get; set; }
       public double longitude { get; set; }
       public Address2 address { get; set; }
       public object comment { get; set; }
       public object airport { get; set; }
   }
   public class Address2
   {
       public string display_address { get; set; }
       public string building_number { get; set; }
       public string street_name { get; set; }
       public string city { get; set; }
       public string region { get; set; }
       public string postal_code { get; set; }
       public string country { get; set; }
   }
  </code></pre>
  
  <p>Assign the values to the object</p>
  
  <pre><code>Request request =new Request();
  request.vehicles  = new List&lt;Vehicle&gt;();
  </code></pre>
  
  <p>// and so on</p>
  
  <pre><code>//Use Newtonsoft.Json to serialize the object as:
  var json = JsonConvert.SerializeObject(request);
  //Invoke your request with json
  using (var response = await httpClient.PostAsync("{supplier_id}/availability?version=2", json))
  {
      string responseData = await response.Content.ReadAsStringAsync();
  }
  </code></pre>
  
  <p>but my method show error</p>
  
  <pre><code> public void ConvertJson()
           {
               BookingInformation objbooking = new BookingInformation();
               objbooking.booking_id = "33";
               objbooking.to_location.comment= "Saloon black";
               objbooking.to_location.address.country= "UK";
               var json = JsonConvert.SerializeObject(objbooking);
           }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/8nuBT.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8nuBT.jpg" alt="enter image description here"></a></p>