我可以在不同的命名空间中创建部分类吗?它会正常工作吗?例如:
将Class1.cs
namespace name1
{
public partial class Foo
{
Bar1(){
return 10;
}
}
}
Run Code Online (Sandbox Code Playgroud)
class2.cs
namespace name1.name2
{
public partial class Foo
{
Bar2(){
return 100;
}
}
}
Run Code Online (Sandbox Code Playgroud)
main.cs
using name1;
using name1.name2;
namespace mainClass
{
public class mainClass
{
Foo classFoo = new Foo();
int Count = classFoo.Bar1() + classFoo.Bar2();
// Will Count = 110?
}
}
Run Code Online (Sandbox Code Playgroud)
我该怎么做才能让它发挥作用?(如果我的例子不正确)
如何使用FormsAuthentication保存内容?我不想通过URL存储UserId.
例如,现在我有这个代码:
//UserController class:
[HttpPost]
public ActionResult LogOn(LogOnModel model, string returnUrl)
{
if (ModelState.IsValid)
{
if (repository.ValidateUser(model.Login, model.Password))
{
FormsAuthentication.SetAuthCookie(model.Login, model.RememberMe);
if (Url.IsLocalUrl(returnUrl))
{
return Redirect(returnUrl);
}
else
{
return RedirectToAction("Project", "Index");
}
}
else
{
ModelState.AddModelError("", "Incorrect name or password.");
}
}
return View(model);
}
Run Code Online (Sandbox Code Playgroud)
ProjectController 类:
public ViewResult Index()
{
return View(repository.GetUserProjects(
this.ControllerContext.HttpContext.User.Identity.Name));
}
Run Code Online (Sandbox Code Playgroud)
ProjectRepository:
ProjectsContext context = new ProjectsContext();
UsersContext uCnt = new UsersContext();
public IEnumerable<Project> GetUserProjects(String username)
{
if (String.IsNullOrEmpty(username))
throw new ArgumentNullException("username", "Login is …Run Code Online (Sandbox Code Playgroud) 我正在处理当前项目的问题,我需要一些帮助:
strtoupper(),mb_strtoupper()等不工作setlocale(LC_ALL, "rus");或者setlocale(LC_ALL, "Russian_Russia.1251");对于其他人(我不知道所有其他人是否)setlocale(LC_ALL, 'ru_RU');但是我找到的所有操作系统检测方法都使用strupper()/ strtolower()检测操作系统......所以现在我有些困惑.我该怎么办.如何检测OS ...
顺便说一句,性能是至关重要的,如果有人知道检测操作系统的好方法和设置正确的语言环境,那就太棒了!