public class Rectangle
{
private int width, height;
public Rectangle(int width, int height)
{
this.width = width;
this.height = height;
}
public void OutputArea()
{
Console.WriteLine("Area output: " + Rectangle.CalculateArea(this.width, this.height));
}
public static int CalculateArea(int width, int height)
{
return width * height;
}
}
I like the author's example using Rectangle.CalculateArea( this.width, this.height) as an example of using a static member in a non-static class.
No comments:
Post a Comment