Например, если я хочу добавить расширение к Console под названием '
Код: Выделить всё
WriteBlueLineКод: Выделить всё
Console.WriteBlueLine("This text is blue");
Код: Выделить всё
thisКод: Выделить всё
public static class Helpers {
public static void WriteBlueLine(this Console c, string text)
{
Console.ForegroundColor = ConsoleColor.Blue;
Console.WriteLine(text);
Console.ResetColor();
}
}
Код: Выделить всё
WriteBlueLineПодробнее здесь: https://stackoverflow.com/questions/249 ... atic-class
Мобильная версия