The type or namespace name 'Places' could not be found (are you missing a using directive or an assembly reference?)

Viewed 873

I have a very simple code and some very simple files.
I have created a C# file to insert some data and make a collection of pins from it but when I do it, it gives me this error:

Error CS0246 The type or namespace name 'Places' could not be found (are you missing a using directive or an assembly reference?)

My code:

DATA.cs

using System;
using System.Collections.Generic;
using System.Text;

namespace Orbage
{
    class DATA
    {
        string Label = "USA",
            Address = "This is the US",
            Lat = "40.060407",
            Lng = "-102.453091";
    }
}

MapPage.cs(here is the error)

using System.Collections.Generic;
using Xamarin.Forms.Maps;
using Xamarin.Forms;
using System.IO;
using Newtonsoft.Json;

namespace Orbage
{
    class MapPage : ContentPage
    {
        public MapPage()
        {
            CustomMap customMap = new CustomMap
            {
                MapType = MapType.Street

            };
            // ...
            Content = customMap;

            var json = File.ReadAllText("DATA");

            var places = JsonConvert.DeserializeObject<List<Places>>(json);
            foreach (var place in places)
            {
                CustomPin pin = new CustomPin
                {
                    Type = PinType.Place,
                    Position = new Position(place.lat,place.lng),
                    Label = place.Label,
                    Address = place.Address,
                    Name = "Xamarin",

                    Url = "http://xamarin.com/about/"
                };

                customMap.CustomPins = new List<CustomPin> { pin };

                customMap.Pins.Add(pin);
                customMap.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(37.79752, -122.40183), Distance.FromMiles(1.0)));
            }
        }
    }
}

I guess this all the code which is needed. I hope this is enough.

I used the following answers as reference:

1 Answers

There are lot of issues in your code.

I am trying to fix only related to the question you have raised.

It should be DATa not Place, you need to declare the properties as public and change from lat to Lat and so....

class DATA
{
    public string Label = "USA";
    public string Address = "This is the US";
    public string Lat = "40.060407";
    public string Lng = "-102.453091";
}


var places = JsonConvert.DeserializeObject<List<DATA>>(json);
                foreach (var place in places)
                {
                    CustomPin pin = new CustomPin
                    {
                        Type = PinType.Place,
                        Position = new Position(place.Lat, place.Lng),
                        Label = place.Label,
                        Address = place.Address,
Related