2015-05-04 120 views
0

我正在通过一个关于YouTube的ASP.NET MVC 5教程。我真的很喜欢它。但是,我被困在似乎是一个奇怪的错误。奇怪的意思我认为我有教程中输入的所有内容,但VS2013正在标记我,我无法弄清楚什么可能是错的。将数学变量定义为课程似乎很好。但是,它不喜欢数学。ASP.NET MVC 5教程错误:无法找到类型或名称空间名称

enter image description here

型号/ 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; } 
    } 
} 

控制器/ 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(); 
      ..... 
      ..... 
+2

似乎没有什么是你的代码错误只是尝试清洗液并重建公众。 –

+1

注意:您已在课程POCO模型中将所有属性创建为私有。我认为这本来是要公开的。 –

+0

我试过清洁和重建。然后关闭并重新打开。什么是私人?我不熟悉术语POCO。也许这就是为什么我不明白。 – abalter

回答

1

清洁并重新生成解决方案作为Jenish Rabadiya在评论中提及。

更新

使属性在下面的类

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

IT没有工作:( – abalter

+0

现在它工作:) – abalter

相关问题