Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



How to convert string to int

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 04-06-2009
Member
 
Join Date: Jun 2009
Posts: 347
How to convert string to int
  

I have string s="somecomments" which i need to convert to its integer equivalent. Is it possible ?

Can anyone tell me how to convert an int to a string value that I define? Please help.

Reply With Quote
  #2  
Old 04-06-2009
Member
 
Join Date: Feb 2009
Posts: 673
Re: How to convert string to int

TO covert string to Int32, take this function:

Quote:
public static int ParseInt(object o, int defaultValue)
{
if (o == null || o == DBNull.Value)
{
return defaultValue;
}
try
{
return Int32.Parse(o.ToString(), CultureInfo.InvariantCulture);
}
catch (Exception ex)
{
if (!(ex is FormatException) && !(ex is InvalidCastException) && !(ex
is OverflowException))
{
throw;
}
return defaultValue;
}
}
Reply With Quote
  #3  
Old 04-06-2009
Member
 
Join Date: Feb 2009
Posts: 161
Re: How to convert string to int

you can make a function some like this to convert string to int:-


Quote:
<%

' CInt Converts to Integer
' CStr Converts to String
' TypeName Returns subtype variable for your control

a = Cint(1)
b = Cstr(1)

Response.Write(TypeName(a)) & "<br>"
Response.Write(TypeName(b))

%>
Reply With Quote
  #4  
Old 04-06-2009
Member
 
Join Date: Apr 2008
Posts: 4,098
Re: How to convert string to int

just use the Convert methods,, Convert.ToInt32(textbox1.text).the only valid conversion would be a string of the character codes for each character in a string.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags:



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to convert string to int"
Thread Thread Starter Forum Replies Last Post
Convert string into int in C screwball Software Development 4 22-12-2011 07:47 PM
Convert XML string into DOM GreatThinker Software Development 6 22-07-2010 09:48 AM
How to convert string into int in Java Zool Software Development 3 09-11-2009 11:41 AM
Convert a string in decimal FlayoFish Software Development 3 23-04-2009 12:18 PM
Convert a string to bytes $tatic Software Development 4 18-02-2009 01:29 PM


All times are GMT +5.5. The time now is 07:46 PM.