<code executed if <test>is true>
<code executed if <test>is false>
<code executed if <test>is true>
<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);
}
}
}
任意输入两个数其运行结果是:
本文转自shenzhoulong 51CTO博客,原文链接:http://blog.51cto.com/shenzhoulong/288394,如需转载请自行联系原作者