parameterized Method

using System;
class Rectangle
{
    public double width, height;
    public void setVal(double w, double h)
    {
        width = w;
        height = h;
    }
    public double area()
    {
        return width * height;
    }
}

using System;
class Program
{
    public static void Main(String[] args)
    {
        Rectangle rec = new Rectangle();
        rec.setVal(5.0, 7.0);
        Console.WriteLine("The area of the Rectangle is: " + rec.area());
        Console.ReadKey();
    }
}

No comments:

Post a Comment