Note that there are some explanatory texts on larger screens.

plurals
  1. POInconsistent accessibility when everything is public
    primarykey
    data
    text
    <p>I am trying to Deserialize a JSON response from Google Maps Geocode.</p> <p>Those are the classes I coded based on the response.</p> <pre><code>public class GoogleGeoCodeResponse { public string status { get; set; } public results[] results { get; set; } } public class results { public address_component[] address_components { get; set; } public String formatted_address { get; set; } public Geometry geometry { get; set; } public Boolean partial_match { get; set; } public string[] types { get; set; } } public class address_component { public String long_name { get; set; } public String short_name { get; set; } public String[] types { get; set; } } public class Geometry { public bounds_viewport bounds { get; set; } public LatLong location { get; set; } public String location_type { get; set; } } public class bounds_viewport { public LatLong northeast { get; set; } public LatLong southwest { get; set; } } public class LatLong { public double lon { get; set; } public double lat { get; set; } } </code></pre> <p>On my form button click I use this code.</p> <pre><code>var json = new WebClient().DownloadString("url"); GoogleGeoCodeResponse test = JsonConvert.DeserializeObject&lt;GoogleGeoCodeResponse&gt;(json); MessageBox.Show(test.results[0].geometry.location.lat + " / " + test.results[0].geometry.location.lon); </code></pre> <p>Then I wanted to see if I get the correct information but I'm getting:</p> <p>"Error 1 Inconsistent accessibility: property type 'WindowsFormsApplication1.results[]' is less accessible than property 'WindowsFormsApplication1.GoogleGeoCodeResponse.results'"</p> <p>I've looked a bunch of post with the same problem but they always had something private or internal somewhere that would lead to this error. As you can see everything I declared is public.</p> <p>I don't understand why something public inside of a class would be more accessible than the class itself.</p> <p>I am fairly new to C# and JSON so this might be something really simple.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload