ASP.NET MVC 5教程错误:找不到类型或命名空间名称

时间:2020-12-09 16:46:27

I'm working through an ASP.NET MVC 5 tutorial on YouTube. I'm really enjoying it. However, I'm stuck on what seems to be a strange error. Strange meaning I think I have everything typed in as in the tutorial, but VS2013 is flagging me, and I can't figure out what might be wrong. Defining the math variable as a Course seems fine. However, then it doesn't like math.

我正在YouTube上完成ASP.NET MVC 5教程。我真的很享受。但是,我坚持看似奇怪的错误。奇怪的意思我认为我已经在教程中输入了所有内容,但VS2013正在标记我,我无法弄清楚可能出错的地方。将数学变量定义为课程似乎很好。但是,它不喜欢数学。

ASP.NET MVC 5教程错误:找不到类型或命名空间名称

Models/Course.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace MyfirstProject.Models
{
    public class Course
    {
        int CourseID { get; set; }
        string CourseName { get; set; }
        int TotalCredits { get; set; }
    }
}

Controllers/XyzController.cs

using MyfirstProject.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace MyfirstProject.Controllers
{
    public class XyzController : Controller
    {
        // GET: Xyz
        public ActionResult Abc()
        {
            Course math = new Course();
            .....
            .....

1 个解决方案

#1


Clean and rebuild the solution as Jenish Rabadiya mentioned in comment.

正如Jenish Rabadiya在评论中提到的那样,清理并重建解决方案。

Update

Make the attributes public in the following class

在以下类中将属性设置为public

 public class Course
{
    public int CourseID { get; set; }
    public string CourseName { get; set; }
    public int TotalCredits { get; set; }
}

#1


Clean and rebuild the solution as Jenish Rabadiya mentioned in comment.

正如Jenish Rabadiya在评论中提到的那样,清理并重建解决方案。

Update

Make the attributes public in the following class

在以下类中将属性设置为public

 public class Course
{
    public int CourseID { get; set; }
    public string CourseName { get; set; }
    public int TotalCredits { get; set; }
}