流程控制语句:if语句,其基本语法是:
  if <test>
     <code executed if <test>is true>
  else
    <code executed if <test>is false>
当然也可以嵌套,其形式是:
if <test>
{
     <code executed if <test>is true>
}
  else
{
    <code executed if <test>is false>
}
一下是简单实例:两个数的比较
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication5
{
    class Program
    {
        static void Main(string[] args)
        {
            string comparison;
                Console.WriteLine("请输入一个数字");
                double var1 = Convert.ToDouble(Console.ReadLine());
                Console.WriteLine("请输入另一个数");
                double var2 = Convert.ToDouble(Console.ReadLine());
            if(var1<var2)
                comparison="小于";
            else
            {
                if(var1>var2)
                    comparison="大于";
                else
                    comparison=("等于");
            }
            Console.WriteLine("第一个数{0}第二个数",comparison);
        }
          
    }
}c#判断两个数的大小(2)

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-19
  • 2022-12-23
  • 2022-01-30
  • 2021-11-13
  • 2021-12-18
猜你喜欢
  • 2021-09-24
  • 2022-12-23
  • 2022-12-23
  • 2022-03-04
  • 2022-12-23
  • 2022-12-23
  • 2022-01-06
相关资源
相似解决方案