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.
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.
TO covert string to Int32, take this function:
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;
}
}
you can make a function some like this to convert string to int:-
<%
' 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))
%>
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.
Bookmarks