请帮助我找到以下代码的解决方案 [英] pls help me to find the solution for below code

查看:67
本文介绍了请帮助我找到以下代码的解决方案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

public class CustomerController : Controller
{
   …..
   ….
   public ViewResult DisplayCustomer()
   {
      Customer objCustomer = new Customer();//i can not creat an object of this class bcoz i can not find this Customer class here so how to find this class here..?
      objCustomer.Id = 12;
      objCustomer.CustomerCode = "1001";
      objCustomer.Amount = 90.34;

      return View("DisplayCustomer",objCustomer);
   }
}



请解决我对此代码的注释部分
缺少什么,所以我在这里找不到"Customer"类...



please solve my comment part of this code
what is missing so i can not find "Customer" class here...

推荐答案

您需要在Customer的开头对Customer所属的名称空间使用using语句模块代码.如果它在同一个项目中,则不需要对包含客户定义的项目进行引用(在项目根目录下的references文件夹中).否则,您需要通过右键单击引用"文件夹并选择添加引用..."来添加引用.文件夹中的项目将显示在项目"选项卡(即左上方的选项卡)下.
You need a using statment for the namespace that Customer belongs to at the beginning of the module code. If it is in the same project, then you do not need to have a reference to the project containing the definition of Customer (in the references folder under the root of the project). Otherwise you need to add a reference by right clicking the references folder and selecting "Add Reference...". Projects within the folder will appear under the Projects tab, which is the top left tab.


我确信这是简单的方法,因此无法满足您的需求但是在我看来,您正在尝试实例化项目中不存在的类.在您的项目中包括一个文件(可能称为Customer.cs),或使用解决方案所需的所有适当属性等创建Customer类.

阅读 [
I''m sure this is way to simple so can''t be what you are looking for but it seems to me that you are attempting to instantiate a class that does not exist in your project. Either include a file (probably called Customer.cs) in your project or create the Customer class with all of the appropriate properties, etc., that your solution requires.

Read this[^].


这篇关于请帮助我找到以下代码的解决方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆