Click here to Skip to main content
15,881,172 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Application["ApplicationVisitorCount"].ToString() in Global.asax file.

I want to convert it into integer.
Posted
Updated 8-Jun-18 0:19am

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);


But among of all I think the TryParse is best.

Please vote and Accept Answer if it Helped.
 
Share this answer
 
Try Integer.Parse() or Integer.TryParse()

Good luck!
 
Share this answer
 
string num = "123";
int parse =int.Parse(num);
 
Share this answer
 
Use
Convet.ToInt32(Application["ApplicationVisitorCount"].ToString())

Convet.ToInt32 will not throw null exceptions

Hope this will help you :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900