如何使用C#在.aspx中使用if语句 [英] How to use if statements in .aspx using C#

查看:481
本文介绍了如何使用C#在.aspx中使用if语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个简单的例子来说明如何使用C#在.aspx文件中使用if语句来比较两个数字或两个字符串。

I need a simple example to show how to use if statements in .aspx file using C# to compare tow numbers or two strings.

推荐答案

你好Ardeshir225,

Hi Ardeshir225,

这个例子可以帮助你,并且在.net中编写if语句的约定与winform应用程序,web应用程序或wcf服务相同。希望这能帮到你。

This example might help you and also writing convention of if-statement in .net are same wheather it winform application, web application or wcf service. Hope this helps you.

using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int number;

            Console.WriteLine("Please enter a number between 0 and 10:");
            number = int.Parse(Console.ReadLine());

            if(number > 10)
                Console.WriteLine("Hey! The number should be 10 or less!");
            else
                if(number < 0)
                    Console.WriteLine("Hey! The number should be 0 or more!");
                else
                    Console.WriteLine("Good job!");

            Console.ReadLine();
        }
    }
}

谢谢,

沙巴沙里克


这篇关于如何使用C#在.aspx中使用if语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆