1
Vote

Lesson 24: Inconsistent accessibility error

description

Hi,
I've been following along with the lessons, and learning a lot. Thank you very much!

I'm experiencing a hiccup tho. It seems we can not nest a public class inside a private collection. I tried changing the modifier to public for the ObservableCollection<Car> but that didn't work either.
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BindingToCommands
{
    class Car
    {
        public int ID { get; set; }
        public string Make { get; set; }
        public string Model { get; set; }
        public string CheckedinDateTime { get; set; }

    }

    public class CarDataSource
    {
        private static ObservableCollection<Car> _cars
            = new ObservableCollection<Car>();

        public static ObservableCollection<Car> GetCars()
        {
            if (_cars.Count == 0)
            {
                _cars.Add(new Car() {ID = 1, Make = "Oldsmobile", Model = "Cutlas Supreme"});
                _cars.Add(new Car() {ID = 2, Make = "BMW", Model="550li" });
                _cars.Add(new Car() {ID = 3, Make = "Honda", Model = "Accord" });

            }
            return _cars;
        }
    }
}
Severity    Code    Description Project File    Line
Error   CS0053  Inconsistent accessibility: property type 'ObservableCollection<Car>' is less accessible than property 'MainPage.CarsViewModel' BindingToCommands   c:\users\gds_000\documents\visual studio 2015\Projects\BindingToCommands\BindingToCommands\MainPage.xaml.cs 30
Error   CS0050  Inconsistent accessibility: return type 'ObservableCollection<Car>' is less accessible than method 'CarDataSource.GetCars()'    BindingToCommands   c:\users\gds_000\documents\visual studio 2015\Projects\BindingToCommands\BindingToCommands\Car.cs   24
Microsoft Visual Studio Community 2015
Version 14.0.23107.0 D14REL
Microsoft .NET Framework
Version 4.6.00081

comments

GaryStewart wrote Aug 7, 2015 at 8:13 PM

Ah. I think I figured it out :) I didn't set my Car class to public. whew can continue now