logo
Учебник_ПОА

Comparisons

The simplest way to compare two strings is to use the == and != symbols, which perform a case-sensitive comparison.

string color1 = "red";

string color2 = "green";

string color3 = "red";

if (color1 == color3)

{

System.Console.WriteLine("Equal");

}

if (color1 != color2)

{

System.Console.WriteLine("Not equal");

}