Материал из .Net Framework эксперт
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Char compare (C#)
<%@ 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:<br />
<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>
<br />
ASCII number of first character in each box:<br />
<asp:Label id="lblASC1" runat="server"></asp:Label>
<asp:Label id="lblASC2" runat="server"></asp:Label>
<br />
<br />
<asp:Label id="lblOut" runat="server"></asp:Label>
<br />
<br />
</form>
</body>
</html>