Programming in C# with Microsoft Visual Studio 2010
Contents
Module 1: Introducing C# and the .NET Framework
Lesson 1: Introduction to the .NET Framework 4
Lesson 2: Creating Projects Within Visual Studio 2010
Lesson 3: Writing a C# Application
Lesson 4: Building a Graphical Application
Lesson 5: Documenting an Application
Lesson 6: Debugging Applications by Using Visual Studio 2010
Lab: Introducing C# and the .NET Framework
1-4
1-16
1-33
1-44
1-58
1-66
1-78
Module 2: Using C# Programming Constructs
Lesson 1: Declaring Variables and Assigning Values
Lesson 2: Using Expressions and Operators
Lesson 3: Creating and Using Arrays
Lesson 4: Using Decision Statements
Lesson 5: Using Iteration Statements
Lab: Using C# Programming Constructs
2-4
2-23
2-36
2-49
2-63
2-78
Module 3: Declaring and Calling Methods
Lesson 1: Defining and Invoking Methods
Lesson 2: Specifying Optional Parameters and Output Parameters
Lab: Declaring and Calling Methods
3-3
3-29
3-39
Module 4: Handling Exceptions
Lesson 1: Handling Exceptions
Lesson 2: Raising Exceptions
Lab: Handling Exceptions
4-3
4-23
4-34
vi
Programming in C# with Microsoft Visual Studio 2010
Module 5: Reading and Writing Files
Lesson 1: Accessing the File System
Lesson 2: Reading and Writing Files by Using Streams
Lab: Reading and Writing Files
5-3
5-27
5-45
Module 6: Creating New Types
Lesson 1: Creating and Using Enumerations
Lesson 2: Creating and Using Classes
Lesson 3: Creating and Using Structures
Lesson 4: Comparing References to Values
Lab: Creating New Types
6-3
6-12
6-33
6-41
6-55
Module 7: Encapsulating Data and Methods
Lesson 1: Controlling Visibility of Type Members
Lesson 2: Sharing Methods and Data
Lab: Encapsulating Data and Methods
7-4
7-15
7-29
Module 8: Inheriting from Classes and Implementing Interfaces
Lesson 1: Using Inheritance to Define New Reference Types
Lesson 2: Defining and Implementing Interfaces
Lesson 3: Defining Abstract Classes
Lab: Inheriting from Classes and Implementing Interfaces
8-3
8-27
8-45
8-56
Module 9: Managing the Lifetime of Objects and Controlling Resources
Lesson 1: Introduction to Garbage Collection
Lesson 2: Managing Resources
Lab: Managing the Lifetime of Objects and Controlling Resources
9-4
9-21
9-35
Module 10: Encapsulating Data and Defining Overloaded Operators
Lesson 1: Creating and Using Properties
Lab A: Creating and Using Properties
Lesson 2: Creating and Using Indexers
Lab B: Creating and Using Indexers
10-4
10-26
10-38
10-50
Programming in C# with Microsoft Visual Studio 2010
Lesson 3: Overloading Operators
Lab C: Overloading Operators
vii
10-60
10-79
Module 11: Decoupling Methods and Handling Events
Lesson 1: Declaring and Using Delegates
Lesson 2: Using Lambda Expressions
Lesson 3: Handling Events
Lab: Decoupling Methods and Handling Events
11-4
11-14
11-22
11-38
Module 12: Using Collections and Building Generic Types
Lesson 1: Using Collections
Lab A: Using Collections
Lesson 2: Creating and Using Generic Types
Lesson 3: Defining Generic Interfaces and Understanding Variance
Lesson 4: Using Generic Methods and Delegates
Lab B: Building Generic Types
12-4
12-22
12-28
12-42
12-56
12-69
Module 13: Building and Enumerating Custom Collection Classes
Lesson 1: Implementing a Custom Collection Class
Lesson 2: Adding an Enumerator to a Custom Collection Class
Lab: Building and Enumerating Custom Collection Classes
13-3
13-21
13-37
Module 14: Using LINQ to Query Data
Lesson 1: Using the LINQ Extension Methods and Query Operators
Lesson 2: Building Dynamic LINQ Queries and Expressions
Lab: Using LINQ to Query Data
14-3
14-28
14-47
Module 15: Integrating Visual C# Code with Dynamic Languages and COM
Components
Lesson 1: Integrating Visual C# Code with Ruby and Python
Lesson 2: Accessing COM Components from Visual C#
Lab: Integrating Visual C# Code with Dynamic Languages and COM
Components
15-4
15-19
15-36