C# - 不一致的可访问性:返回类型列表的可访问性低于方法

Duk*_*uke -2 c#

namespace BusinessLayer
{
    public class StudentBusinessLayer
    {
        public List<Student> getStudents(string storedProcedure)
        {
            using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString))
            {
                List<Student> students = new List<Student>();
                SqlCommand comm = new SqlCommand(storedProcedure, conn);
                comm.CommandType = CommandType.StoredProcedure;
                conn.Open();
                SqlDataReader rdr = comm.ExecuteReader();
                while (rdr.Read())
                {
                    Student s = new Student();
                    s.id = Convert.ToInt32(rdr["id"]);
                    s.Name = rdr["Name"].ToString();
                    s.TotalMarks = Convert.ToInt32(rdr["TotalMarks"]);

                    students.Add(s);
                }
                return students;
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

Tha*_*uni 5

看来你的Student课不是public,让它public修复你的错误。