[C#]等値演算子を使用して等値を判定
書式
値1==値2
使用例
using System;
class ArkgameDemo
{
public static void Main()
{
//int型変数の宣言
int x = 23;
int y = 23;
int z = 34;
//string型変数の宣言
string strA = "study";
string strB = "Study";
//Boolean型変数の宣言
Boolean res1 = (x == y);
Boolean res2 = (x == z);
Boolean res3 = (strA == strB);
Console.WriteLine("等値の判定結果1: " + res1.ToString());
Console.WriteLine("等値の判定結果2: " + res2.ToString());
Console.WriteLine("等値の判定結果3: " + res3.ToString());
Console.ReadKey();
}
}
実行結果
等値の判定結果1: True
等値の判定結果2: False
等値の判定結果3: False