Is there any way I can add a static extension method to a class.
specifically I want to overload Boolean.Parse
to allow an int
argument.
This question is related to
c#
extension-methods
specifically I want to overload
Boolean.Parse
to allow an int argument.
Would an extension for int work?
public static bool ToBoolean(this int source){
// do it
// return it
}
Then you can call it like this:
int x = 1;
bool y = x.ToBoolean();
No, but you could have something like:
bool b;
b = b.YourExtensionMethod();
Source: Stackoverflow.com