Although you are using Calculation as a class, you ultimately are attempting to define an operation on a cylinder. A cylinder can be expressed by a height and radius (properties), and is a useful construct for exposing methods (like "Get the volume of the cylinder.").
Let's begin there and define the Cylinder class:
class Cylinder { public double Radius; public double Height; public double GetVolume() { return Math.PI * Radius * Radius * Height; } // Constructor public Cylinder(double radius, double height) { this.Radius = radius; this.Height = height; } }
Note that this is a simple class with two fields (radius, height), a method (GetArea), and a constructor. It encapsulates the data needed to construct and perform operations on a cylinder. All of these members are public, which means that they can be accessed by programs that use the class. (Private members, by contrast, can only be used inside the class.)
Now we can build a program that makes use of the class:
class Program { static Cylinder GetCylinderFromUser() { double radius, height; Console.Write("Enter radius: "); radius = double.Parse(Console.ReadLine()); Console.Write("Enter height: "); height = double.Parse(Console.ReadLine()); return new Cylinder(radius, height); } static void Main() { Cylinder c = GetCylinderFromUser(); Console.WriteLine("Created cylinder with height={0} and radius={1}", c.Height, // replaces {0} with height of c c.Radius // replaces {1} with radius of c ); double volume = c.GetVolume(); Console.WriteLine("The volume of the cylinder is {0}.", volume); Console.ReadLine(); } }
This is a very basic example, but note that the program is broken into small pieces that are then coupled together. The classes separate out the user interface (getting the user-provided input) from the calculation logic. The Cylinder class can be reused in other contexts, and internal logic can be adjusted without affecting other parts of the code.
refunless you have a specific reason to.