Method with return type

using System;
class Rectangle
{
    public double width, height;

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

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

No comments:

Post a Comment