Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace NM1
- {
- public class Rectangle
- {
- //variables
- private int length;
- private int breadth;
- //getters setters
- public int Length
- {
- get { return length; }
- set { length = value; }
- }
- public int Breadth
- {
- get { return breadth; }
- set { breadth = value; }
- }
- // WHEN THE CONSTRUCTOR IS DEFINED HERE THE ERROR ARISES IN THE INHERITED CLASS
- public Rectangle(int passedLength, int passedBreadth)
- {
- this.length = passedLength;
- this.breadth = passedBreadth;
- }
- public void rectangleArea()
- {
- Console.WriteLine("The area of the rectangle is : " + (Length * Breadth));
- }
- }
- }
- namespace NM2
- {
- public class Square : NM1.Rectangle
- {
- public void calculateSquare()
- {
- Console.WriteLine("The length is inherited from rectangle : ---> " + this.Length);
- Console.WriteLine("The area of the sqaure is : " + (this.Length * this.Length));
- }
- }
- class programs
- {
- public static void Main()
- {
- Square s = new Square();
- s.Length = 12;
- s.Breadth = 14;
- s.calculateSquare();
- s.rectangleArea();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement