C#中的Int32.Equals()方法示例
Int32.Equals()方法
此方法用于比较两个整数对象,并返回布尔值true或false。
语法:
bool int.equals(int objA, int objB);
Parameter(s):
intobjA,intobjB–用于表示两个要比较的整数对象。
返回值:
bool-如果两个对象相等,则返回“true”,否则返回“false”。
Int32.Equals()C#中的方法示例
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int a = 0;
int b = 0;
Console.Write("Enter A: ");
a = Convert.ToInt32(Console.ReadLine());
Console.Write("Enter B: ");
b = Convert.ToInt32(Console.ReadLine());
if (int.Equals(a, b) == true)
{
Console.WriteLine("Both are equal");
}
else
{
Console.WriteLine("Both are not equal");
}
}
}
}输出结果
Enter A: 10 Enter B: 15 Both are not equal Enter A: 10 Enter B: 10 Both are equal
热门推荐
10 八一幼儿祝福语大全简短
11 公司乔迁食堂祝福语简短
12 婚礼结束聚餐祝福语简短
13 儿媳买车妈妈祝福语简短
14 毕业送礼老师祝福语简短
15 同事辞职正常祝福语简短
16 恭贺新婚文案祝福语简短
17 金店立秋祝福语简短英文
18 婆婆高寿祝福语大全简短