110,891
社区成员
发帖
与我相关
我的任务
分享
public static int Max(int val1, int val2)
{
if (val1 < val2)
{
return val2;
}
return val1;
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int a, b;
a = 10;
b = 11;
//Console.WriteLine("{0}",a>b?a:b);
Console.WriteLine("{0}",a.CompareTo(b));
//当a>b时,a.CompareTo(b)==1
//当a=b时,a.CompareTo(b)==0
//当a<b时,a.CompareTo(b)==-1
Console.ReadKey();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int a, b;
a = 10;
b = 11;
Console.WriteLine("{0}",a>b?a:b);
Console.ReadKey();
}
}
}