a_elnajjar — 2012-01-24T01:49:17-05:00 — #1
Hi I am trying to create extend methodes for math class by adding a couple of Trigonometric formula I just want to see if I am in the right track or not
static class Trigonometric
private double m_hypotenuse_C;
private double m_side1_A;
private double m_side2_B;
// TODO: Complete member initialization
public Trigonometric(double side1, double side2)
m_side1_A = side1;
m_side2_B = side2;
public Trigonometric(double hypotenuse, double side1_a, double side2_b)
m_hypotenuse_C = hypotenuse;
m_side1_A = side1_a;
m_side2_B = side2_b;
public double GetHypotenuse()
double side1 = Math.Pow(m_side1_A, 2);
double side2 = Math.Pow(m_side2_B, 2);
double totalOFsides = side1 + side2;
static double GetTriangleSide()
double hypotenuse = Math.Pow(m_hypotenuse_C, 2);
double side = Math.Pow(m_side1_A, 2);
double value = hypotenuse - side;
static double GetTheta()
double result = m_side2_B / m_hypotenuse_C;
return theta = Math.Asin(result);
wwb_99 — 2012-01-24T08:11:46-05:00 — #2
You don't really need extension methods here, you need to use both the public and the static keywords on your methods. Static classes cannot have instance (non-static) members.
alex69 — 2012-02-29T14:55:10-05:00 — #3
For Math it seems to be impossible to create extensions. It is possible only for non-static types, which allow to create objects.
public static class Extensions
public static double MyExtension(this string str, int arg)
... put your logic here ...
Make sure that you create a public static method in a public static class.
mittineague — 2014-09-17T23:33:38-04:00 — #4
This topic is now archived. It is frozen and cannot be changed in any way.