
68Microsoft Visual Studio 2010: A Beginner’s Guide
Key Skills & Concepts
●Create Classes
●Write Methods
●Code Fields and Properties
Atype is a general term for classes, modules, enums, and more. This chapter will specifically discuss the class type, which allows you to create your own custom types.
You’ll also see the value of a class when you learn about class members. You’ll see how the field, method, and property class members can be used. We’ll start with learning how to create and use classes.
Creating Classes
Previously, you learned about the primitive types, which are built into languages and alias the underlying .NET types. You can also create your own types, via classes, which you can instantiate and create objects with. The following section explains how to create
a class and then instantiate an object from it.
Class Syntax
To create a new custom class definition,
Listing 3-1 A new Employee class
C#:
using System;
using System.Collections.Generic; using System.Linq;
using System.Text; namespace FirstProgram