Sorry, I think you're right about that. I can't figure out how to add an extension method to System.Math either.
You cannot create an instance of a static class, so you can't use one as a parameter when building the extension method.
Static classes are also sealed, so you can't inherit from them. That paragraph says you don't need to inherit from the Math class, which sort of also implies that you might want to do that, but it's not allowed.
Interestingly (at least I think it's sort of interesting) you can extend a sealed class (such as int), but not a static one.
I think that paragraph was badly worded. The paragraph goes on to say that it won't add an extension method to the Math class, but instead will extend the int type. That *is* possible.
I think what the author meant was that you can add functionality as if it were provided by the Math class, in this example by extending int.
Sorry about the confusion.
|