I was trying to write a simple extension method for Color static class which return Black and White equivalent of that color.
The problem is that extention methods can’t return Static types…
So, how can I do this?! please help me.
I was trying to write a simple extension method for Color static class which
Share
The problem is that NO method can return a static type. Static classes are stateless (or have only static state), and thus have only one “instance” that is globally accessible from any code referencing the namespace.
You can return a Color; the Color class itself, though it has static members, is not static, and so many instances of Colors can exist. You can also apply an extension method to a Color. If you do this, then you can call an extension method on one of the static members of the non-static Color struct: