ASP.Net/Language Basics/Char
Версия от 18:30, 26 мая 2010; (обсуждение)
Char compare (C#)
<source lang="csharp">
<%@ Page Language="C#" Debug="true" %> <script runat="server">
void Page_Load() { int intASC1, intASC2; intASC1 = Convert.ToInt32(Convert.ToChar(txtIn1.Text)); intASC2 = Convert.ToInt32(Convert.ToChar(txtIn2.Text)); lblASC1.Text = Convert.ToString(intASC1); lblASC2.Text = Convert.ToString(intASC2); if (intASC1 > intASC2){ lblOut.Text = "Left is considered greater then right"; lblOutSign.Text = ">"; } else if (intASC1 < intASC2) { lblOut.Text = "Left is considered less then right"; lblOutSign.Text = "<"; }else if (intASC1 == intASC2) { lblOut.Text = "Left is considered equal to right"; lblOutSign.Text = "= ="; }else{ lblOut.Text = "Does not compute"; lblOutSign.Text = "?"; } }
</script> <html> <head>
<title>Demonstrate String Comparison</title>
</head> <body>
<form runat="server"> Please enter a single character in each box:
<asp:TextBox id="txtIn1" runat="server">a</asp:TextBox> <asp:Label id="lblOutSign" runat="server"> </asp:Label> <asp:TextBox id="txtIn2" runat="server">a</asp:TextBox> <asp:Button id="Button1" runat="server" Text="Submit"></asp:Button>
ASCII number of first character in each box:
<asp:Label id="lblASC1" runat="server"></asp:Label> <asp:Label id="lblASC2" runat="server"></asp:Label>
<asp:Label id="lblOut" runat="server"></asp:Label>
</form>
</body> </html>
</source>