title: Cannot implicitly convert type 'string' to 'int'
body: <p>I am not the best in C# as I currently still learning as I go! However, I got stuck on assigning parsed JSON values from an asset file.</p>
  
  <p>The parsing works fine, and I can locate a path. However, the value is retrieved as an object, and I cannot convert it into an integer which is the current JSON value.</p>
  
  <p>How would I go about retrieving the JSON value in the correct format? Either being string or int.</p>
  
  <p>I've tried <code>Convert.ToInt32(reader.Value)</code> AND <code>(int) reader.Value</code> as you can see below.</p>
  
  <p>But I receive the error <code>Cannot implicitly convert type 'string' to 'int'</code></p>
  
  <p>Also, I've tried <code>JsonConvert.DeserializeObject&lt;T&gt;(reader.Value)</code></p>
  
  <p>Which gives two errors:</p>
  
  <ul>
  <li><code>The type or namespace name 'T' could not be found</code></li>
  <li><code>Argument 1: cannot convert from 'object to 'string'</code></li>
  </ul>
  
  <p><strong>Note:</strong> CustomerVolumes() is just a getter/setter mapping class of complete JSON response. Some values are strings or integers. Nothing special!</p>
  
  <p><strong>Using:</strong> <a href="http://www.newtonsoft.com/json/help/html/T_Newtonsoft_Json_JsonReader.htm" rel="nofollow noreferrer">http://www.newtonsoft.com/json/help/html/T_Newtonsoft_Json_JsonReader.htm</a>
  <br/>And <strong>also</strong> used: <a href="http://json2csharp.com" rel="nofollow noreferrer">http://json2csharp.com</a> to create <strong><em>CustomerVolumes</em></strong> class</p>
  
  <pre><code>public class DashboardActivity : Activity
  {
      protected override void OnCreate(Bundle savedInstanceState)
      {
          base.OnCreate(savedInstanceState);
          SetContentView(Resource.Layout.Dashboard);
  
          string  jsonResponse      = ReadFile();
          var     CustomerVolumes   = new CustomerVolumes();
  
          JsonTextReader reader = new JsonTextReader(new StringReader(@jsonResponse));
  
          while (reader.Read())
          {
              if (reader.Value != null)
              {
                  if (reader.Path.Equals("customers.id.cycles.yyyy_mm.scopes.mms.volume") &amp;&amp; !reader.Value.Equals("volume"))
                  {
                      CustomerVolumes.customers.id.cycles.yyyy_mm.scopes.mms.volume = Convert.ToInt32(reader.Value);
                  }
  
                  if (reader.Path.Equals("customers.id.cycles.yyyy_mm.scopes.gprs.volume") &amp;&amp; !reader.Value.Equals("volume"))
                  {
                      CustomerVolumes.customers.id.cycles.yyyy_mm.scopes.gprs.volume = (int) reader.Value;
                  }
          }
      }
  
      private string ReadFile()
      {
          StreamReader sr = new StreamReader(Android.App.Application.Context.Assets.Open(JSON_FILE));
          string text     = sr.ReadToEnd();
                            sr.Close();
  
          return text;
      }
  }
  
  public class Mms
  {
      public int volume { get; set; }
  }
  
  public class Gprs
  {
      public int volume { get; set; }
  }
  
  public class Voice
  {
      public int volume { get; set; }
  }
  
  public class Sms
  {
      public int volume { get; set; }
  }
  
  public class Scopes
  {
      public Mms mms { get; set; }
      public Gprs gprs { get; set; }
      public Voice voice { get; set; }
      public Sms sms { get; set; }
  }
  
  public class YyyyMm
  {
      public Scopes scopes { get; set; }
  }
  
  public class Cycles
  {
      public YyyyMm yyyy_mm { get; set; }
  }
  
  public class Id
  {
      public Cycles cycles { get; set; }
  }
  
  public class Customers
  {
      public Id id { get; set; }
  }
  
  public class CustomerVolumes
  {
      public Customers customers { get; set; }
  }
  </code></pre>