Код: Выделить всё
public static bool operator ==(string a, string b)
{
return string.Equals(a, b);
}
public static bool operator !=(string a, string b)
{
return !string.Equals(a, b);
}
Код: Выделить всё
private static void Main()
{
String str = "Hello ";
str += "World";
Console.WriteLine(str);
}
Итак, почему же System.String не перегружает оператор + = это объединяет строку?
Подробнее здесь: https://stackoverflow.com/questions/144 ... -works-how
Мобильная версия