有没有一种基于.NET / C#isset()函数的? [英] is there a sort of isset() on .NET/C#?

查看:126
本文介绍了有没有一种基于.NET / C#isset()函数的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要检查是否有对URI请求的参数。

I need to check if there is a param on the uri request.

所以,我需要检查,如果该参数设置。是否有.NET函数/ C#?

So I need to check if that param is set. Is there a function on .NET/C#?

推荐答案

这是未设置值为null或空:

An unset value will be null or empty:

value = Request["param"];
if (String.IsNullOrEmpty(value))
{
    // param is not set
}

如果该PARAM NAME是在查询字符串,但该值不是,这将是空的。如果名字不在查询字符串,其值将为空。例如,

If the param name is in the query string but the value is not, it will be empty. If the name is not in the query string, the value will be null. For example.

&param1=&param2=value 
// Request["param1"] is String.Empty
// Request["param3"] is null

这篇关于有没有一种基于.NET / C#isset()函数的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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