I would like to add a custom WriteColoredText
method to the Console
Class, to acces like this:
Console.WriteColoredText(Parametters)
The problem is that I only found information about creating method extensions for specific datatypes but any about a method extension for a Class.
If this is not possibly, which similar alternatives I have?
The short answer is, you can't.
Extension methods can only apply to object instances, but the
Console
class is static. The only solution is to write your own, completely separate class, sayConsoleEx
, and implement any methods you want there.