#205 – Five Kinds of Types That Are User-Definable

C# allows you to create new types.  There are five kinds of types that you can define.

A class is a data structure containing data and its associated behavior.  You can create an instance of a class using the new keyword, giving you an object.

A struct is similar to a class, containing data and behavior.  But an instance of a struct is created on the stack, rather than the heap.

An interface defines a set of methods, properties and events that a class can implement.  It is just a description of what a class needs to implement, in order to fully implement the interface.

A delegate is a definition of a method signature, which includes the data type of the method’s parameters and return value.  An instance of a delegate type references a specific method.

An enum type represents a set of named constants.

Advertisements