[我的ASP.net学习历程]类型转换

类别:Asp 点击:0 评论:0 推荐:
<%@ Page Language="C#" AutoEventWireup="True" %>
<Script language="C#" runat="server">
void Page_Load(Object Sender,EventArgs e){
 int IntStr;
 string Str;
 char CharStr;
 if (!IsPostBack){
  Label_1.Text="Please input Number string in TextBox!";
  }
 else{
  IntStr=Int32.Parse(Input_1.Value);  //字符串型转换成整型
  Str=IntStr.ToString();  //整型转换成字符串型
  CharStr=Str[1];  //把字符串中的第二个字符赋值给字符型变量
  Response.Write(CharStr);
  }
}
</Script>
<form id="Form_1" runat="server">
<input id="Input_1" type="text" runat="server"/>
<input id="Button_1" type="Submit" value="Button" runat="server"/>
</form>
<asp:label ID="Label_1" runat="server"></asp:label>

本文地址:http://com.8s8s.com/it/it8589.htm