c#里怎么判断接收到的参数是为数字型,或者为字符型?

renaski 2004-10-23 05:13:15
我想判断一下,然后如果不是的话,就跳转。
...全文
130 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
renaski 2004-10-23
  • 打赏
  • 举报
回复
是这样

我接受到的比方说
id=6
我怎么来判断这个6是数字呢?
Request("id")
要判断这个是数字,而不是其他类型
happyjun2000 2004-10-23
  • 打赏
  • 举报
回复
GetType()
顶,接点分^_^
无聊就接分来了
yanransoft 2004-10-23
  • 打赏
  • 举报
回复
private void whatType(object temp)
{
if(temp.GetType()== typeof(System.String))
{
MessageBox.Show("参数类型是字符串");
}
}
hanbinghai 2004-10-23
  • 打赏
  • 举报
回复
是判断参数内容还是参数类型?
判断参数类型:
private void whatType(object temp)
{
if(temp.GetType().ToString() == "System.String")
{
MessageBox.Show("参数类型是字符串");
}
}
在代码中调用:
string str1 = "1";
this.whatType(str1);
ckwangfg 2004-10-23
  • 打赏
  • 举报
回复
http://community.csdn.net/Expert/FAQ/FAQ_Index.asp?id=107996

110,536

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧