Classes

Classes are data structures that contain data (or fields) and methods and properties to manipulate this data. Classes support inheritance, so one class can be derived from another and extend the base class' functionality or simply take advantage of the work previously done. Listing A.4 shows a simple Point class.

Listing A.4. A Simple Point Class Declaration
1: using System;
2:3: class Point{
4:    public double X = 0;
5:    public double Y = 0;
6:7:    public void print(){
8:       Console.WriteLine("(" + X + ", " + Y + ")" );
9:    }
10:
11: } // End of Point Class

Listing A.4 shows a very simple Point class. Lines 4 and 5 show the two public fields X and Y, which are double value types.

Lines 7 through 9 show the Point class, which contains a print() ...

Get Building e-Commerce Sites with the .NET Framework now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.