木子屋 Dnawo's BLOG

ASP.NET MVC3接收参数小测试

👤 dnawo 📅 2013-09-12 👁 3683 👍 0 💬 0 🔄 本站原创
测试一

public ActionResult Index(string arg)
{
    if (arg == null)
    {
        return Content("null");
    }
    else if (arg == "")
    {
        return Content("empty");
    }
    else
    {
        return Content(arg);
    }
}

图片

测试二

public ActionResult Index(int? arg)
{
    if (arg == null)
    {
        return Content("null");
    }
    else
    {
        return Content(arg.ToString());
    }
}

图片
说明:第2个null应是empty转化的结果。

测试三

public ActionResult Index(Test test)
{
    return Content(test.arg1 + "," + test.arg2);
}

图片

评论(0)

暂无评论。

计算题
评论需审核通过后显示
← 上一篇 ASP.NET MVC3视图占位符RenderSection使用… 下一篇 → 淘宝供销平台产品发布到淘宝店铺示例