输入字符串格式不正确.. [英] input string is not in correct formate..

查看:80
本文介绍了输入字符串格式不正确..的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所有,当我写下面时



int id = Convert.ToInt16(System.Web.HttpContext.Current.Session.SessionID);



它显示没有错误,在excution时它表示输入字符串不正确格式化



什么是错误在上面这一行...... ??以及为什么IDE不允许我这样编写



int id = Convert.Int16(System.Web.HttpContext.Current .Session.SessionID);



请帮帮我..



谢谢和问候

hai all,when i write below

int id = Convert.ToInt16(System.Web.HttpContext.Current.Session.SessionID);

it shows no error and int the time of exicution it says input string is not correct formate

what is the error in the above line...??and why IDE did't allow me to write like

int id = Convert.Int16(System.Web.HttpContext.Current.Session.SessionID);

please help me..

Thanks and Regards

推荐答案

您好,



您错误地解决问题。你不能使用整数。



SessionID是一个不是整数的字符串,所以很可能它不会转换为整数。

请参阅: http:// msdn.microsoft.com/en-us/library/system.web.sessionstate.httpsessionstate.sessionid(v=vs.110).aspx [ ^ ]



你可以做的是:

Hello,

You take the problem the wrong way round. You wont be able to use a integer.

SessionID is a string not an integer, so it's likely that it wont convert to an integer.
See here: http://msdn.microsoft.com/en-us/library/system.web.sessionstate.httpsessionstate.sessionid(v=vs.110).aspx[^]

What you can do is:
string id = System.Web.HttpContext.Current.Session.SessionID;





Valery。



Valery.


这篇关于输入字符串格式不正确..的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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