Log In
Or create an account ->
Imperial Library
Home
About
News
Upload
Forum
Help
Login/SignUp
Index
Learning C# 2005
Dedication
A Note Regarding Supplemental Files
Preface
About This Book
Who This Book Is For
How the Book Is Organized
Conventions Used in This Book
Using Code Examples
Support
We’d Like to Hear from You
Safari® Enabled
Acknowledgments
Jesse Liberty
Brian MacDonald
1. C# and .NET Programming
C# 2005 and .NET 2.0
The .NET Platform
The .NET 2.0 Framework
The C# Language
The Structure of C# Applications
The Development Environment
What’s in a Program?
Your First Program: Hello World
The Compiler
Examining Your First Program
Summary
Quiz
Exercise
2. Visual Studio 2005
Before You Read Further
Start Page
Projects and Solutions
Web Sites
Templates
Inside the Integrated Development Environment
Building and Running
Menus and Toolbars
File Menu
Edit Menu
Cycle Clipboard Ring
Find and Replace
Go To ...
Find All References
Insert File As Text ...
Advanced
Incremental search
Bookmarks
Outlining
IntelliSense
View Menu
Class View
Code Definition
Error List
Output
Properties
Task List
Toolbox
Other windows
Refactor Menu
Project Menu
Build Menu
Debug Menu
Data Menu
Format Menu
Tools Menu
Connect To Device
Connect To Database
Code Snippets Manager
Choose Toolbox Items
External Tools
Performance Tools
Import and Export Settings
Options
Window Menu
Help Menu
Summary
Quiz
Exercise
3. C# Language Fundamentals
Statements
Types
Numeric Types
Non-Numeric Types: char and bool
Types and Compiler Errors
Variables
Definite Assignment
Constants
Literal Constants
Symbolic Constants
Enumerations
Strings
Expressions
Whitespace
Summary
Quiz
Exercises
4. Operators
The Assignment Operator (=)
Mathematical Operators
Simple Arithmetical Operators (+, -, *, / )
The modulus Operator (%)
Increment and Decrement Operators
Calculate and Reassign Operators
Increment or Decrement by 1
The Prefix and Postfix Operators
Relational Operators
Use of Logical Operators with Conditionals
The Conditional Operator
Operator Precedence
Summary
Quiz
Exercises
5. Branching
Unconditional Branching Statements
Conditional Branching Statements
if Statements
Single-Statement if Blocks
Short-Circuit Evaluation
if ... else Statements
Nested if Statements
switch Statements
Falling-Through and Jumping-to Cases
Switch on string Statements
Iteration (Looping) Statements
Creating Loops with goto
The while Loop
The do ... while Loop
The for Loop
Controlling a for loop with the modulus operator
Breaking out of a for loop
The continue statement
Optional for loop header elements
The while (true) construct
Summary
Quiz
Exercises
6. Object-Oriented Programming
Creating Models
Classes and Objects
Defining a Class
Class Relationships
The Three Pillars of Object-Oriented Programming
Encapsulation
Specialization
Polymorphism
Object-Oriented Analysis and Design
Summary
Quiz
Exercises
7. Classes and Objects
Defining Classes
Instantiating Objects
Creating a Time Class
Access Modifiers
Method Arguments
Constructors
Initializers
The this Keyword
Static and Instance Members
Invoking Static Methods
Using Static Fields
Destroying Objects
Memory Allocation: The Stack Versus the Heap
Summary
Quiz
Exercises
8. Inside Methods
Overloading Methods
Encapsulating Data with Properties
The get Accessor
The set Accessor
Returning Multiple Values
Passing Value Types by Reference
out Parameters and Definite Assignment
Summary
Quiz
Exercises
9. Basic Debugging
Setting a Breakpoint
Using the Debug Menu to Set Your Breakpoint
Setting Conditions and Hit Counts
Examining Values: The Autos and Locals Windows
Set Your Watch
The Call Stack
Summary
Quiz
Exercises
10. Arrays
Using Arrays
Declaring Arrays
Understanding Default Values
Accessing Array Elements
The foreach Statement
Initializing Array Elements
The params Keyword
Multidimensional Arrays
Rectangular Arrays
Jagged Arrays
Array Methods
Sorting Arrays
Summary
Quiz
Exercises
11. Inheritance and Polymorphism
Specialization and Generalization
Inheritance
Implementing Inheritance
Calling Base Class Constructors
Controlling Access
Polymorphism
Creating Polymorphic Types
Versioning with new and override
Abstract Classes
Sealed Classes
The Root of All Classes: Object
Boxing and Unboxing Types
Boxing Is Implicit
Unboxing Must Be Explicit
Avoiding Boxing with Generics
Summary
Quiz
Exercises
12. Operator Overloading
Using the operator Keyword
Creating Useful Operators
The Equals Operator
Conversion Operators
Summary
Quiz
Exercises
13. Interfaces
Implementing an Interface
Defining the Interface
Implementing the Interface on the Client
Implementing More than One Interface
Casting to an Interface
The is and as Operators
Extending Interfaces
Combining Interfaces
Overriding Interface Implementations
Explicit Interface Implementation
Summary
Quiz
Exercises
14. Generics and Collections
Generics
Collection Interfaces
Creating Your Own Collections
Indexers and Assignment
Indexing on Other Values
Generic Collection Interfaces
The IEnumerable<T> Interface
Framework Generic Collections
Generic Lists: List<T>
Creating objects that can be sorted by the generic list
Controlling how elements in a generic collection are sorted by implementing IComparer<T>
Generic Queues
Generic Stacks
Dictionaries
Summary
Quiz
Exercises
15. Strings
Creating Strings
String Literals
Escape Characters
Verbatim Strings
The ToString( ) Method
Manipulating Strings
Comparing Strings
Concatenating Strings
Copying Strings
Testing for Equality
Other Useful String Methods
Finding Substrings
Splitting Strings
The StringBuilder Class
Regular Expressions
The Regex Class
Summary
Quiz
Exercises
16. Throwing and Catching Exceptions
Bugs, Errors, and Exceptions
Throwing Exceptions
Searching for an Exception Handler
The throw Statement
The try and catch Statements
How the Call Stack Works
Creating Dedicated catch Statements
The finally Statement
Exception Class Methods and Properties
Custom Exceptions
Summary
Quiz
Exercises
17. Delegates and Events
Delegates
Using Delegates to Specify Methods at Runtime
Multicasting
Events
Publishing and Subscribing
Events and Delegates
Solving Delegate Problems with Events
The event Keyword
Using Anonymous Methods
Summary
Quiz
Exercises
18. Creating Windows Applications
Creating a Simple Windows Form
Using the Visual Studio Designer
The partial Keyword
Creating a Real-World Application
Creating the Basic UI Form
Populating the TreeView Controls
TreeNode objects
Recursing through the subdirectories
Getting the files in the directory
Handling TreeView Events
Clicking the source TreeView
Expanding a directory
Clicking the target TreeView
Handling the Clear button event
Implementing the Copy Button Event
Sorting the list of selected files
Handling the Delete Button Event
XML Documentation Comments
Summary
Quiz
Exercises
19. Programming ASP.NET Applications
Understanding Web Forms
Web Form Events
Postback Versus Non-Postback Events
State
Creating a Web Form
Code-Behind Files
Enabling Debugging
Adding Controls
Server Controls
Data Binding
Adding Controls and Events
Summary
Quiz
Exercises
A. Answers to Quizzes and Exercises
Chapter 1: C# and .NET Programming
Quiz
Exercise
Chapter 2: Visual Studio 2005
Quiz
Exercises
Chapter 3: C# Language Fundamentals
Quiz
Exercises
Chapter 4: Operators
Quiz
Exercises
Chapter 5: Branching
Quiz
Exercises
Chapter 6: Object-Oriented Programming
Quiz
Exercises
Chapter 7: Classes and Objects
Quiz
Exercises
Chapter 8: Inside Methods
Quiz
Exercises
Chapter 9: Basic Debugging
Quiz
Exercises
Chapter 10: Arrays
Quiz
Exercises
Chapter 11: Inheritance and Polymorphism
Quiz
Exercises
Chapter 12: Operator Overloading
Quiz
Exercises
Chapter 13: Interfaces
Quiz
Exercises
Chapter 14: Generics and Collections
Quiz
Exercises
Chapter 15: Strings
Quiz
Exercises
Chapter 16: Throwing and Catching Exceptions
Quiz
Exercises
Chapter 17: Delegates and Events
Quiz
Exercises
Chapter 18: Creating Windows Applications
Quiz
Exercises
Chapter 19: Programming ASP.NET Applications
Quiz
Exercises
Index
About the Authors
Colophon
Copyright
← Prev
Back
Next →
← Prev
Back
Next →