ASP.Net/Language Basics/Char — различия между версиями

Материал из .Net Framework эксперт
Перейти к: навигация, поиск
м (1 версия)
 
(нет различий)

Версия 15:30, 26 мая 2010

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">&nbsp;&nbsp;&nbsp;&nbsp;</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>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <asp:Label id="lblASC2" runat="server"></asp:Label>
        <br />
        <br />
        <asp:Label id="lblOut" runat="server"></asp:Label>
        <br />
        <br />
    </form>
</body>
</html>