[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: False
不等値の判定結果2: True
不等値の判定結果3: True