111,125
社区成员
发帖
与我相关
我的任务
分享using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class 新文件夹1_Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string str = "3200r/km";
int a=GetStringToint(str);
Response.Write(a);
}
}
public int GetStringToint(string str)
{
string substr="";
int y = 0;
string error = "";
for (int i = 0; i < str.Length; i++)
{
substr = str.Substring(0,str.Length-i);
try
{
y = Convert.ToInt32(substr);
if (y >= 0)
{
break;
}
}
catch (Exception ex)
{
error = ex.Message;
}
}
return y;
}
}