Home Page Icon
Home Page
Table of Contents for
Index
Close
Index
by Brian MacDonald, Jesse Liberty
Learning C# 3.0
Learning C# 3.0
A Note Regarding Supplemental Files
Preface
About This Book
Who This Book Is For
How This Book Is Organized
Conventions Used in This Book
Support: A Note from Jesse Liberty
Using Code Examples
We’d Like to Hear from You
Safari® Books Online
Acknowledgments
Jesse Liberty
Brian MacDonald
1. C# and .NET Programming
Installing C# Express
C# 3.0 and .NET 3.5
The .NET Platform
The .NET Framework
The C# Language
Your First Program: Hello World
The Compiler
Examining Your First Program
The Integrated Development Environment
Summary
Test Your Knowledge: Quiz
Test Your Knowledge: Exercise
2. Visual Studio 2008 and C# Express 2008
Before You Read Further
The Start Page
Projects and Solutions
Project Types
Templates
Inside the Integrated Development Environment
Building and Running Applications
Menus
The File Menu
The Edit Menu
The Clipboard Ring
Find and Replace
Go To
Insert File As Text
Advanced
Incremental search
Bookmarks
Outlining
IntelliSense
The View Menu
Class View
Code Definition
Error List
Output
Properties
Task List
Toolbox
Other Windows
The Refactor Menu
The Project Menu
The Build Menu
The Debug Menu
The Data Menu
The Format Menu
The Tools Menu
Connect to Device
Device Emulator Manager
Connect to Database
Connect to Server
Code Snippets Manager
Choose Toolbox Items
External Tools
Import and Export Settings
Options
The Window Menu
The Help Menu
Summary
Test Your Knowledge: Quiz
Test Your Knowledge: Exercises
3. C# Language Fundamentals
Statements
Types
Numeric Types
Nonnumeric Types: char and bool
Types and Compiler Errors
WriteLine( ) and Output
Variables and Assignment
Definite Assignment
Implicitly Typed Variables
Casting
Constants
Literal Constants
Symbolic Constants
Enumerations
Strings
Whitespace
Summary
Test Your Knowledge: Quiz
Test Your Knowledge: Exercises
4. Operators
Expressions
The Assignment Operator (=)
Mathematical Operators
Simple Arithmetic Operators (+, –, *, /)
The Modulus Operator (%)
Increment and Decrement Operators
The Calculate and Reassign Operators
Increment or Decrement by 1
The Prefix and Postfix Operators
Relational Operators
Logical Operators and Conditionals
The Conditional Operator
Operator Precedence
Summary
Test Your Knowledge: Quiz
Test Your Knowledge: 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
Fall-Through and Jump-to Cases
Switch on string Statements
ReadLine( ) and Input
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
Summary
Test Your Knowledge: Quiz
Test Your Knowledge: 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
Test Your Knowledge: Quiz
Test Your Knowledge: Exercises
7. Classes and Objects
Defining Classes
Instantiating Objects
Creating a Box Class
Access Modifiers
Method Arguments
Return Types
Constructors
Initializers
Object Initializers
Anonymous Types
The this Keyword
Static and Instance Members
Invoking Static Methods
Using Static Fields
Finalizing Objects
Memory Allocation: The Stack Versus the Heap
Summary
Test Your Knowledge: Quiz
Test Your Knowledge: Exercises
8. Inside Methods
Overloading Methods
Encapsulating Data with Properties
The get Accessor
The set Accessor
Automatic Properties
Returning Multiple Values
Passing Value Types by Reference
out Parameters and Definite Assignment
Summary
Test Your Knowledge: Quiz
Test Your Knowledge: 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
Setting Your Watch
The Call Stack
Stopping Debugging
Summary
Test Your Knowledge: Quiz
Test Your Knowledge: Exercises
10. Arrays
Using Arrays
Declaring Arrays
Understanding Default Values
Accessing Array Elements
Arrays and Loops
The foreach Statement
Initializing Array Elements
The params Keyword
Multidimensional Arrays
Rectangular Arrays
Jagged Arrays
Array Methods
Sorting Arrays
Summary
Test Your Knowledge: Quiz
Test Your Knowledge: Exercises
11. Inheritance and Polymorphism
Specialization and Generalization
Inheritance
Implementing Inheritance
Calling the Base Class Constructor
Hiding the Base Class Method
Controlling Access
Polymorphism
Creating Polymorphic Types
Overriding Virtual Methods
Using Objects Polymorphically
Versioning with new and override
Abstract Classes
Sealed Classes
The Root of All Classes: Object
Summary
Test Your Knowlege: Quiz
Test Your Knowledge: Exercises
12. Operator Overloading
Designing the Fraction Class
Using the operator Keyword
Creating Useful Operators
The Equals Operator
Conversion Operators
Summary
Test Your Knowledge: Quiz
Test Your Knowledge: Exercises
13. Interfaces
What Interfaces Are
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 Methods
Explicit Interface Implementation
Summary
Test Your Knowledge: Quiz
Test Your Knowledge: Exercises
14. Generics and Collections
Generics
Collection Interfaces
Creating Your Own Collections
Creating Indexers
Indexers and Assignment
Indexing on Other Values
Generic Collection Interfaces
The IEnumerable<T> Interface
Framework Generic Collections
Generic Lists: List<T>
Sorting objects with the generic list
Controlling sorting by implementing IComparer<T>
Generic Queues
Generic Stacks
Dictionaries
Summary
Test Your Knowledge: Quiz
Test Your Knowledge: 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
Test Your Knowledge: Quiz
Test Your Knowledge: 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
Test Your Knowledge: Quiz
Test Your Knowledge: Exercises
17. Delegates and Events
Delegates
Events
Publishing and Subscribing
Events and Delegates
Solving Delegate Problems with Events
The event Keyword
Using Anonymous Methods
Lambda Expressions
Summary
Test Your Knowledge: Quiz
Test Your Knowledge: Exercises
18. Creating Windows Applications
Creating a Simple Windows Form
Using the Visual Studio Designer
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 the TreeView Events
Clicking the source TreeView
Expanding a directory
Clicking the target TreeView
Handling the Button Events
Handling the Clear button event
Implementing the Copy button event
Handling the Delete button event
Handling the Cancel button event
Source Code
Summary
Test Your Knowledge: Quiz
Test Your Knowledge: Exercises
19. Windows Presentation Foundation
Your First WPF Application
WPF Differences from Windows Forms
Using Resources
Animations
Triggers and Storyboards
Animations As Resources
C# and WPF
Grids and Stack Panels
Defining ListBox styles
Triggers and animations
Adding Data
Instantiating objects declaratively
Using the Data in the XAML
Defining the ListBox
Event Handling
The Complete XAML File
Summary
Test Your Knowledge: Quiz
Test Your Knowledge: Exercises
20. ADO.NET and Relational Databases
Relational Databases and SQL
Installing the Northwind Database
Tables, Records, and Columns
Normalization
Declarative Referential Integrity
SQL
The ADO.NET Object Model
DataTables and DataColumns
DataRelations
Rows
DataAdapter
DbCommand and DbConnection
DataReader
Getting Started with ADO.NET
Summary
Test Your Knowledge: Quiz
Test Your Knowledge: Exercises
21. LINQ
Querying In-Memory Data
Anonymous Types and Implicitly Typed Variables
Lambda Expressions
Ordering and Joining
Using LINQ with SQL
Using the Object Relational Designer
Summary
Test Your Knowledge: Quiz
Test Your Knowledge: Exercises
A. Answers to Quizzes and Exercises
Chapter 1: C# and .NET Programming
Quiz Solutions
Exercise Solution
Chapter 2: Visual Studio 2008 and C# Express 2008
Quiz Solutions
Exercise Solutions
Chapter 3: C# Language Fundamentals
Quiz Solutions
Exercise Solutions
Chapter 4: Operators
Quiz Solutions
Exercise Solutions
Chapter 5: Branching
Quiz Solutions
Exercise Solutions
Chapter 6: Object-Oriented Programming
Quiz Solutions
Exercise Solutions
Chapter 7: Classes and Objects
Quiz Solutions
Exercise Solutions
Chapter 8: Inside Methods
Quiz Solutions
Exercise Solutions
Chapter 9: Basic Debugging
Quiz Solutions
Exercise Solutions
Chapter 10: Arrays
Quiz Solutions
Exercise Solutions
Chapter 11: Inheritance and Polymorphism
Quiz Solutions
Exercise Solutions
Chapter 12: Operator Overloading
Quiz Solutions
Exercise Solutions
Chapter 13: Interfaces
Quiz Solutions
Exercise Solutions
Chapter 14: Generics and Collections
Quiz Solutions
Exercise Solutions
Chapter 15: Strings
Quiz Solutions
Exercise Solutions
Chapter 16: Throwing and Catching Exceptions
Quiz Solutions
Exercise Solutions
Chapter 17: Delegates and Events
Quiz Solutions
Exercise Solutions
Chapter 18: Creating Windows Applications
Quiz Solutions
Exercise Solutions
Chapter 19: Windows Presentation Foundation
Quiz Solutions
Exercise Solutions
Chapter 20: ADO.NET and Relational Databases
Quiz Solutions
Exercise Solutions
Chapter 21: LINQ
Quiz Solutions
Exercise Solutions
Index
About the Authors
Colophon
Copyright
Search in book...
Toggle Font Controls
Playlists
Add To
Create new playlist
Name your new playlist
Playlist description (optional)
Cancel
Create playlist
Sign In
Email address
Password
Forgot Password?
Create account
Login
or
Continue with Facebook
Continue with Google
Sign Up
Full Name
Email address
Confirm Email Address
Password
Login
Create account
or
Continue with Facebook
Continue with Google
Prev
Previous Chapter
Index
Next
Next Chapter
Index
E
Edit menu,
The Edit Menu
–
The View Menu
,
Go To
,
Advanced
,
Bookmarks
,
Outlining
,
IntelliSense
,
The View Menu
editor in C# Express,
Inside the Integrated Development Environment
–
Building and Running Applications
,
Inside the Integrated Development Environment
,
Inside the Integrated Development Environment
,
Building and Running Applications
else if idiom,
Nested if Statements
else statement,
if . . . else Statements
,
Nested if Statements
emulators,
Device Emulator Manager
encapsulation,
The Three Pillars of Object-Oriented Programming
EndsWith( ) method,
Other Useful String Methods
Enqueue( ) method,
Generic Queues
EnsureCapacity( ) method,
The StringBuilder Class
enum keyword,
Enumerations
enumerations,
Enumerations
–
Whitespace
,
Enumerations
,
Whitespace
equals operator (==),
Relational Operators
equals sign,
Relational Operators
,
Copying Strings
equals sign (=),
Variables and Assignment
,
Operators
,
The Assignment Operator (=)
,
Operator Precedence
,
Copying Strings
Equals( ) method,
The Root of All Classes: Object
,
The Equals Operator
,
Manipulating Strings
,
Testing for Equality
Object,
The Root of All Classes: Object
,
The Equals Operator
strings,
Manipulating Strings
,
Testing for Equality
Error List window,
Error List
errors,
Types and Compiler Errors
,
Bugs, Errors, and Exceptions
,
Bugs, Errors, and Exceptions
compared to exceptions,
Bugs, Errors, and Exceptions
compiler,
Types and Compiler Errors
user causing,
Bugs, Errors, and Exceptions
escape characters,
WriteLine( ) and Output
,
Escape Characters
event handlers,
Events and Delegates
event keyword,
The event Keyword
–
Using Anonymous Methods
,
The event Keyword
,
The event Keyword
,
Using Anonymous Methods
,
Using Anonymous Methods
,
Using Anonymous Methods
event-driven programming,
Delegates and Events
EventArgs class,
Events and Delegates
events (C#),
Delegates and Events
,
Events
,
Publishing and Subscribing
,
Publishing and Subscribing
,
Events and Delegates
–
Solving Delegate Problems with Events
,
Events and Delegates
,
Events and Delegates
,
Solving Delegate Problems with Events
,
Solving Delegate Problems with Events
,
Using the Visual Studio Designer
–
Creating a Real-World Application
,
Using the Visual Studio Designer
,
Using the Visual Studio Designer
,
Using the Visual Studio Designer
,
Creating a Real-World Application
for controls,
Using the Visual Studio Designer
–
Creating a Real-World Application
,
Using the Visual Studio Designer
,
Using the Visual Studio Designer
,
Using the Visual Studio Designer
,
Creating a Real-World Application
implementing with delegates,
Events and Delegates
–
Solving Delegate Problems with Events
,
Events and Delegates
,
Events and Delegates
,
Solving Delegate Problems with Events
,
Solving Delegate Problems with Events
publishing,
Publishing and Subscribing
subscribing to,
Publishing and Subscribing
events (WPF),
Animations
types of,
Animations
Events window,
Using the Visual Studio Designer
,
Using the Visual Studio Designer
,
Using the Visual Studio Designer
EventTrigger element,
Triggers and Storyboards
,
Animations As Resources
examples,
Your First Program: Hello World
,
Examining Your First Program
,
Examining Your First Program
,
Examining Your First Program
,
Polymorphism
,
Creating Indexers
,
WPF Differences from Windows Forms
,
Getting Started with ADO.NET
,
Using LINQ with SQL
,
Using LINQ with SQL
,
Using the Object Relational Designer
,
Using the Object Relational Designer
,
Using the Object Relational Designer
,
Using the Object Relational Designer
complexity of,
Polymorphism
Hello World,
Your First Program: Hello World
,
Examining Your First Program
,
Examining Your First Program
,
Examining Your First Program
Hello WPF,
WPF Differences from Windows Forms
ListBox control,
Creating Indexers
Northwind database,
Getting Started with ADO.NET
,
Using LINQ with SQL
,
Using LINQ with SQL
,
Using the Object Relational Designer
,
Using the Object Relational Designer
,
Using the Object Relational Designer
,
Using the Object Relational Designer
Exception class,
Bugs, Errors, and Exceptions
,
Exception Class Methods and Properties
,
Exception Class Methods and Properties
,
Exception Class Methods and Properties
,
Exception Class Methods and Properties
exception class,
Custom Exceptions
exceptions,
Throwing and Catching Exceptions
,
Throwing Exceptions
,
Exception Class Methods and Properties
,
Exception Class Methods and Properties
,
Exception Class Methods and Properties
–
Custom Exceptions
,
Exception Class Methods and Properties
,
Exception Class Methods and Properties
,
Exception Class Methods and Properties
,
Custom Exceptions
–
Custom Exceptions
,
Custom Exceptions
,
Custom Exceptions
,
Custom Exceptions
,
Custom Exceptions
custom,
Custom Exceptions
–
Custom Exceptions
,
Custom Exceptions
,
Custom Exceptions
,
Custom Exceptions
help file link for,
Exception Class Methods and Properties
message about,
Exception Class Methods and Properties
stack trace for,
Exception Class Methods and Properties
–
Custom Exceptions
,
Exception Class Methods and Properties
,
Exception Class Methods and Properties
,
Exception Class Methods and Properties
,
Custom Exceptions
types of,
Throwing Exceptions
.exe file extension,
The Compiler
,
Projects and Solutions
executable programs,
Projects and Solutions
Exists( ) method,
Generic Lists: List<T>
explicit conversions,
Casting
,
Conversion Operators
explicit keyword,
Conversion Operators
,
Conversion Operators
Expression Blend tool,
Animations
expressions,
Expressions
eXtensible Application Markup Language (XAML),
Windows Presentation Foundation
eXtensible Markup Language (XML),
Your First WPF Application
External Tools,
External Tools
Add Highlight
No Comment
..................Content has been hidden....................
You can't read the all page of ebook, please click
here
login for view all page.
Day Mode
Cloud Mode
Night Mode
Reset