namespace用法
2024-09-25 18:55:10
1、在WCF.Controller中定义了一个UserModel,标记为①
2、在WCF.Controller.Model中定义了一个UserModel(同上,namespace不同),标记为②
3、在WCF.Controller中引用UserModel,没有任何疑问,引用的是①中的UserModel
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc; namespace WCF.Controllers
{
public class HomeController : Controller
{
public ActionResult Index()
{
UserModel userModel = new UserModel();
return View();
} }
} namespace WCF.Controllers
{
public class UserModel
{
public int UserID { get; set; }
public string UserName { get; set; }
}
} namespace WCF.Controllers.Model
{
public class UserModel
{
public int UserID { get; set; }
public string UserName { get; set; }
}
}
4、在WCF.Controller.Model中引用UserModel,没有任何疑问,引用的是②中的UserModel
namespace WCF.Controllers.Model
{
public class HomeController : Controller
{
public ActionResult Index()
{
UserModel userModel = new UserModel();
return View();
} }
}
5、在WCF.Controller.Model.SM中引用UserModel,应该和你猜的一致,会向上搜索,引用的是②中的UserModel
namespace WCF.Controllers.Model.SM
{
public class HomeController : Controller
{
public ActionResult Index()
{
UserModel userModel = new UserModel();
return View();
} }
}
6、删除②中定义的UserModel,引用的将会是①中的UserModel
最新文章
- 机器学习PR:感知机模型
- Android基于XMPP的即时通讯2-文件传输
- vim下使用ctags+taglist
- PHP包含文件函数include、include_once、require、require_once区别总结
- 不同tomcat配置不同的jdk
- Object-C 内存管理及对象
- JS模块化编程之AMD规范(转)
- Spring MVC Controller中GET方式传过来的中文参数会乱码的问题
- 【转】VC++消息钩子编程
- LinkButton和HyperLink的页面跳转用法
- Bone Collector(01背包+记忆化搜索)
- mybatis至mysql插入一个逗号包含值误差
- Windows 8 – Reason 442: Failed to enable Virtual Adapter
- Oracle的基本学习(二)—基本查询
- request.getParameter()及解决数据库中文乱码问题——实习第七天
- 【MVC】会员注册/登录,普通验证,会员名是否注册Ajax验证以及会员邮件验证实现原理
- 基于Mybatis的Dao层的开发
- go跨平台编译
- PSU/OPATCH/OJVM下载页面及安装方式(最实用版)
- 图片轮滚形式A