在ASP.NET中将String转换为Integer [英] Convert String To Integer in ASP.NET

查看:210
本文介绍了在ASP.NET中将String转换为Integer的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Application [ApplicationVisitorCount]。Global.asax文件中的ToString()。



我想将其转换为整数。

Application["ApplicationVisitorCount"].ToString() in Global.asax file.

I want to convert it into integer.

推荐答案

有几种方法可以施放,

例如

There are several ways to cast,
For e.g
string s = "123";

int byCasting = (int)s;
int byParsing = int.Parse(s);

int result;
int.TryParse(s,out result);

int byConverting = Convert.ToInt32(s);





但是我觉得<$ code> TryParse 最好。



投票 接受答案 如果有帮助。



But among of all I think the TryParse is best.

Please vote and Accept Answer if it Helped.


尝试 Integer.Parse() Integer.TryParse()



祝你好运!
Try Integer.Parse() or Integer.TryParse()

Good luck!


string num = "123";
int parse =int.Parse(num);


这篇关于在ASP.NET中将String转换为Integer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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