How to convert a string into an Integer in ASP.net?
Answers were Sorted based on User's Feedback
Answer / guest
by two ways u can do that
1.
int a = Int.Parse("String");
2.
int a = Convert.Int32("String");
Is This Answer Correct ? | 100 Yes | 18 No |
Answer / bhaskar
int A = CInt("String") i think this is the best way
Is This Answer Correct ? | 24 Yes | 7 No |
Answer / sai krishna
If you don't pass integer value, it gives the
exception "Input string was not in a correct format."
Is This Answer Correct ? | 14 Yes | 1 No |
Answer / sai krishna
int a = Convert.ToInt32("2");
int b = Int32.Parse("3");
Response.Write( a.ToString() + " " + b.ToString());
Is This Answer Correct ? | 11 Yes | 1 No |
Answer / sanjay
1))int a=int.Parse("string");
2))int a=Convert.ToInt32("string");
3))int a=(int)"string";
but the string provided should be integer
Is This Answer Correct ? | 9 Yes | 2 No |
int.Parse parses the input (casts in a sense) to an integer
value however it will throw an exception if it cant do it if
the data provided is not numeric. you should use TryParse in
.NET 2.0 to see if it can parse it.
int a = Int.Parse("int");
Convert.ToInt32() converts the string data to a proper true
int32 value, and throws an exception if it can't convert the
value.
int a = Convert.Int32("String");
Is This Answer Correct ? | 5 Yes | 4 No |
Answer / binu
All the above are correct. but if you want the integer value of a string( like 'binu') you have to find its ascii value..
There is no other option
Is This Answer Correct ? | 1 Yes | 0 No |
Differentiate between Server.Transfer and Response.Redirect with functionality? Why we can choose one over the other?
Are xaml file compiled or built on runtime?
What is the difference between Webservice and WCF
What is the function of new view engine in asp.net? : asp.net mvc
Describe the role of inetinfo.exe, aspnet_isapi.dll andaspnet_wp.exe in the page loading process.
Is web config mandatory?
How To Send Value one page to Another Page On MasterMenu Click ? please Tell Me!
what is diffrent between asp & asp.net
1.What r collections? 2.What is .pdb file? 3.Is it possible to provide access to users in master page? 4.What is dirty n Phantom Read(SQL)? 5.What r different isolation levels(SQL)? 6.How to set authentication mode in web.config file?
what is the relation between delegates and events
What is viewstate? What does the "enableviewstate” property do? Whay would I want it on or off?
Describe the diffeerence between inline and code behind?