Inconsistent Accessibility: "Teacher" parameter type is less accessible than "Professor.Insert(Teacher)"

Asked

Viewed 57 times

1

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

And when I pass the mouse shows:

Inconsistent Accessibility: "Teacher" parameter type is less accessible than "Professor.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);
        }
    }
}
  • Did the answer solve your question? Do you think you can accept it? See [tour] if you don’t know how you do it. This would help a lot to indicate that the solution was useful for you. You can also vote on any question or answer you find useful on the entire site (when you have 15 points).

1 answer

1

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

It seems that not coding thinking about accessibility, the existing field should not 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 your contract requires needs to be public.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.