It is correct to write the same method PublicMethod of this example as static and non-static i? Is there some effect on performance invoking the non-static method or the compiler will optimize the code?
public class MyClass
{
private double y;
private double PrivateFunc(double x) { return some_operation(x,y);}
public static double PublicFunc(MyClass A, double x)
{
return A.PrivateFunc(x);
}
public double PublicFunc(double x)
{
return MyClass.PublicFunc(this,x);
}
/* instead of repeating code of the static method
public double PublicFunc(double x)
{
return PrivateFunc(this,x);
}
*/
}