#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.

Advertisement

About Sean
Software developer in the Twin Cities area, passionate about software development and sailing.

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

  1. Pingback: #725 – Dumping Out a List of Types in an Assembly « 2,000 Things You Should Know About C#

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: