visual studio - How to Set up an Area method in a C# Program -


okay, have started learn basic of coding in c# visual studio 2015 , life of me can not figure out how set area method using 2 length , width variables. here snippet code:

class rvent : vent {     private int w;      //constructor     public rvent(double w, double l, string rn) : base (w, l,rn)     {         width = w;         length = l;         roomname = rn;     }       //area method rectangle      //area = l*w     public void area()     {          //double operator *(double w, double l);         area = (length * width);     } 

i have searched google , have visited forums , not able grasp doing wrong? appreciated, thank you.

area method. it's action, can't assign value it, can call it, , use value returns you. currently, method signature says aren't returning value. want change method return value represents area:

public double area() {     return length * width; } 

note methods denote action, named verbs. you'd call method getarea().


Comments