Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
402 B
1
Indexable
Never
var circle  = new Circle(2);
Console.WriteLine(circle.GetArea());

public class Circle
{
    public const double Pi = 3.14; // You can assign a value at the time of declaration
    public readonly int Radius;

    public Circle(int radius)
    {
        Radius = radius; //  you can assign a value in the constructor
    }

    public double GetArea()
    {
        return Pi * Radius * Radius;
    }
}