Inconsistent accessibility: parameter type " teacher "is less accessible than method" teacher.Insert (Teacher)"

What do I do to fix this error? It turns red under the methods created in this code.

And when I hover the mouse shows:

Inconsistent accessibility: parameter type " teacher "is less accessible than method" teacher.Insert (Teacher) '

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

namespace Escola.clsDados.BLL
{
    public class Professor
    {
        DAL.Professor dalProf = new DAL.Professor();

        public void Insert(Model.Professor oProf)
        {
            if (oProf.Nome == "")
            {
                throw new Exception("O campo nome é obrigatório");
            }
            dalProf.Insert(oProf);
        }

        public void Update(Model.Professor oProf)
        {
            if (oProf.Nome != "")
                dalProf.Update(oProf);
        }

        public void Delete(Model.Professor oProf)
        {
            if (oProf.Codigo > 0)
                dalProf.Delete(oProf);
        }
    }
}
 1
Author: Maniero, 2020-07-02

1 answers

Probably need to do Model.Professor as public to use in a public method.

Doesn't seem to encode with accessibility in mind, shouldn't the existing field be private? Just because it works doesn't mean it's right.

You cannot access a type that is not accessible in certain situations, so if you have a public method what its contract requires needs to be public.

 1
Author: Maniero, 2020-07-03 12:51:54