How to extend Math class
-
How to add to it more functions and still use Math.SomeFunction() convention. Math class is static, that is sealed. Is it possible to use partial or any other mechanisms?
chesnokov
-
How to add to it more functions and still use Math.SomeFunction() convention. Math class is static, that is sealed. Is it possible to use partial or any other mechanisms?
chesnokov
Chesnokov Yuriy wrote:
How to add to it more functions and still use Math.SomeFunction() convention. Math class is static, that is sealed. Is it possible to use partial or any other mechanisms?
You can't. Create your own utility class for the additional functions.
Upcoming FREE developer events: * Developer Day Scotland Recent blog posts: * Follow up on hiring a software developer * Aarrgghh!! Accidentally pressing the Caps Lock key My website | blog
-
How to add to it more functions and still use Math.SomeFunction() convention. Math class is static, that is sealed. Is it possible to use partial or any other mechanisms?
chesnokov
-
How to add to it more functions and still use Math.SomeFunction() convention. Math class is static, that is sealed. Is it possible to use partial or any other mechanisms?
chesnokov
Use a utility class like this public static class AdvancedMath { //Only if you want to call the method from here //Or rewrite the signature of the methods/properties you want public static decimal Abs(decimal value) { return Math.Abs(value); } //add any additional methods/properties you may have public static double MySpecialMethod(double value) { //do your special processing and return the result } }
-
How to add to it more functions and still use Math.SomeFunction() convention. Math class is static, that is sealed. Is it possible to use partial or any other mechanisms?
chesnokov
Just create your own math class.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer