Log In
Or create an account ->
Imperial Library
Home
About
News
Upload
Forum
Help
Login/SignUp
Index
Title Page
Copyright Page
About the Author
Dedication
Contents
Acknowledgments
Introduction
Part I Programming Basics
1 Introduction to C# Coding and Debugging
Brief History of C#
Understanding Basic Code Terminology
Comments
Syntax
Indentation
Writing and Running a Program
Writing and Editing Your Code
Program Compilation and Execution
Try This 1-1: Creating Your First C# Program
Using the Integrated Development Environment
Creating a Console Application Project
Compiling and Running a Program
Stopping the Application
Saving the Solution
Exiting the Solution
Opening the Solution
Renaming a Code File
Renaming Code Structures
Incorporating Debugging Techniques
Errors and Warnings
Breakpoints
Resuming Program Execution
Tooltips
Stepping into Methods
Stepping over Methods
The Call Stack Window
The Locals Window
Try This 1-2: Inspecting Your Code
The Watch Window
Try-Catch Blocks
Logging Data
Chapter 1 Self Test
2 Variables, Constants, Arrays, and Enumerations
Data Types
Numeric Literals
Variables
Variable Types
Variable Syntax
Variable Names
Constants
Constant Syntax
Constant Names
Try This 2-1: Practice with Variable and Constant Structures
Explicit Variable Conversion (Casting)
Implicit Variable Conversion
Arrays
Array Syntax
Try This 2-2: Practice with Arrays
Array Length
Sorting Arrays
Multidimensional Arrays
Enumerations
Enumeration Syntax
Enumeration Naming
Enumeration Methods
Chapter 2 Self Test
3 Numeric Operators and Routines
Basic Calculations
Addition
Subtraction
Multiplication
Division
Remainder
Exponentiation
Square Root
Increment Operator
Pre-Increment Expressions
Post-Increment Expressions
Try This 3-1: Operator Practice
Decrement Operator
Pre-Decrement Expressions
Post-Decrement Expressions
Randomization
The Default Random Constructor
The Seeded Random Constructor
Try This 3-2: Reusing a Seed Value
Chapter 3 Self Test
4 Methods and Scope
Method Syntax
Calling a Method
Indentation
Try This 4-1: Method Implementation Practice
Method Overloads
Passing Arguments by Value and by Reference
Passing Arguments by Value
Passing Arguments by Reference
Passing Arguments Explicitly by Reference
Passing Uninitialized Variables by Reference
Scope
Class Scope
Method Scope
Block Scope
Variable Precedence
Try This 4-2: Examining Scope
Chapter 4 Self Test
5 Conditional Structures and Loops
Control Structures
Indentation and Alignment
Nesting
Comparison Operators
Equals and Not Equals Operators
Less Than and Greater Than Operators
AND and OR Operators
Conditional Structures
If-Else Statements
Try This 5-1: Comparison Operator and If-Else Statement Practice
Conditional (Ternary) Operators
Switches
Loops
For Loops
Try This 5-2: Nested Loops
While Loops
Do While Loops
Foreach Loops
Comparing Loop Types
Break Statements
Continue Statement
Chapter 5 Self Test
6 String Manipulation
Numeric Format Specifiers
Raw Text
Rounding
Rounding with a Thousands Separator
Displaying Local Currency
Parsing Strings
Length
IndexOf()
LastIndexOf()
Substring
Split()
Try This 6-1: String Formatting and Parsing Exercise
Join()
StartsWith()
Contains()
Editing Strings
Trim()
Concatenation
Adjusting Letter Case
Replace()
Insert()
Remove()
Escape Sequences
Verbatim String Literals
Regular Expressions
Introductory Expressions
More Regular Expression Operators
Try This 6-2: Regular Expression Exercise
Converting Strings to Other Formats
Convert
TryParse()
Chapter 6 Self Test
7 Date and Time Handling
TimeSpan Syntax
TimeSpan Properties
TimeSpan Calculations
TimeSpan Addition
TimeSpan Subtraction
TimeSpan Comparison
Try This 7-1: TimeSpan Practice
DateTime Syntax
System Time
DateTime Properties
Formatting DateTime Output
DateTime Calculations
Adding Units of Time
Try This 7-2: DateTime Practice
DateTime Subtraction
DateTime Comparison
Chapter 7 Self Test
Part II Object-Oriented Programming
8 Encapsulation Through Object-Oriented Programming
Encapsulation
Accessibility
Classes
Objects
Class Declarations
Keyword This
Constructors
Try This 8-1: Class Creation, Constructor, and Accessor Exercise
Properties
Destructors
Static Structures
Declaring Static Structures
Try This 8-2: Examining Static Structures
Structs
Namespaces
Partial Classes
Chapter 8 Self Test
9 Inheritance
Inheritance Introduction
Declaring a Child Class
Protected Members
Try This 9-1: Inheritance Exercise
Inherited Constructor Overloading
Virtual Inheritance
Declaring Virtual Methods
Overriding Virtual Methods
Declaring Virtual Properties
Overriding Virtual Properties
Abstract Inheritance
Declaring Abstract Classes
Declaring Abstract Methods
Overriding Abstract Methods
Declaring Abstract Properties
Overriding Abstract Properties
Virtual and Abstract Comparison
Try This 9-2: Abstraction Exercise
Polymorphism
Sealed Modifiers
Sealing Classes
Sealing Members
Chapter 9 Self Test
10 Generic Types and Collections
Generic Types
Declaring Generic Templates
Generic Constructors
Declaring and Initializing Objects of a Generic Class or Struct
Generic Methods
Generic Properties
Generic Variables
Try This 10-1: Practice with Generic Types
List Collections
List Methods
Try This 10-2: Practice with List Collections
ArrayList Collections
Determining Object Types
ArrayList Methods
KeyValuePair Types
Dictionary Collections
Dictionary Methods
Iterating Through Dictionary Items
Hashtable Collections
Hashtable Methods
Iterating Through Hashtable Items
Chapter 10 Self Test
Part III Advanced Structures
11 Delegates, Anonymous Functions, and Events
Delegates
Delegate Syntax
Try This 11-1: Practice with Delegates
Anonymous Functions
Anonymous Functions with Delegates
Try This 11-2: Practice with Delegates and Anonymous Functions
Anonymous Functions with Func<T,TResult> Delegates
Events
Event Declaration Syntax
Subscribing to an Event
Raising an Event
Unsubscribing from an Event
Chapter 11 Self Test
12 Interfaces
Interface Syntax
Try This 12-1: Interface Exercise
Try This 12-2: Generating Code from the Interface
Explicit Interface Implementation
Implicit Interface Implementation
Interface Hierarchies
Generic Interfaces
Existing .NET Interfaces
IReadOnlyCollection
IComparable
Chapter 12 Self Test
Part IV Data-Driven Development
13 Database Setup
Accessing Database Resources for This Book
Creating a Database Connection String
Browsing Database Content with Visual Studio
Try This 13-1: Examining Table Data
Examining Database Column Detail
Try This 13-2: Examining Database Column Detail
Chapter 13 Self Test
14 The Entity Framework
The Entity Data Model
Adding an Entity Data Model to Your Code Project
Querying Database Objects with the Entity Data Model
DbContext
Entities
DbSet
Querying Entities
Try This 14-1: Querying Entities with the Entity Data Model
Updating the Entity Data Model
Replacing the Entity Data Model
LINQ to Entities Introduction
Lazy Loading and Deferred Execution
Immediate (Eager) Data Loading
LINQPad
Try This 14-2: Observing Query Differences with LINQPad
Chapter 14 Self Test
15 LINQ to Entities: Query Syntax
Read Queries
Referencing Properties of an Object
Assigning Custom Property Names
Try This 15-1: Reading Data with Query Syntax
Lazy Loading vs. Immediate Data Loading
Filtering
Reading One Object Only
Sorting
Subselection
Try This 15-2: Inspecting Combined Queries
Merging Similar Queries with a Union
Aggregate Summary Queries
Adding Objects
Updating Objects
Deleting Objects
Chapter 15 Self Test
16 LINQ to Entities: Method-Based Syntax
Lambda Syntax
Read Queries
Filtering
Try This 16-1: Basic Extension Methods
Filtering with a Collection of Values
Retrieving Similar Matches
Selecting Distinct Rows
Sorting
Subselection
Merging Similar Queries with a Union
Aggregate Summary Queries
Try This 16-2: Aggregate Queries with Simple Grouping
Inserting, Updating, and Deleting Objects
Chapter 16 Self Test
17 Join Queries with LINQ to Entities
Introductory Relational Database Theory
Primary Keys
Composite Primary Key
Foreign Keys
Cardinality
Navigation Properties
Try This 17-1: Testing Your Knowledge of Database Theory
Equal Joins
Equal Joins with Query Syntax
Equal Joins with Method-Based Syntax
Equal Joins with Navigation Properties
Try This 17-2: Practice with Equal Joins
Equal Joins on Composite Keys
Outer Joins
Left Outer Joins
Right Outer Joins
Full Outer Joins
Joining More Than Two Collections in One Query
Bridging Many-to-Many Relationships
Querying Bridge Table Objects
Inserting Bridge Table Objects
Deleting Bridge Table Objects
Chapter 17 Self Test
18 Traditional Database Development
SQL
Stored Procedures
.NET Classes for Managing Database Data
DataTable
DataColumn
DataRow
Try This 18-1: Constructing and Using Your Own DataTable
Referencing Your Connection String in C#
Memory-Based Database Management with the SqlDataAdapter Class
Initializing a SqlDataAdapter Object
Retrieving Data with the SqlDataAdapter Class
Timing Out
Try This 18-2: Executing SQL from Your C# Code
Managing Stored Procedures with the SqlDataAdapter Class
Streaming Data with the SqlDataReader Class
Managing the Database Connection
Chapter 18 Self Test
19 File Input Output
Writing and Reading Plain Text
StreamWriter
StreamReader
Try This 19-1: Writing, Reading, and Extracting Text Data
Writing and Reading Binary Data
FileMode
BinaryWriter
BinaryReader
Try This 19-2: Writing and Reading Binary Data
Reading Buffered Binary Data
Randomly Accessing Binary Data
Chapter 19 Self Test
20 XML Handling
XML Introduction
XML Elements and Attributes
Element Hierarchy
Adding an XML Document to a Visual Studio Project
Well-Formed XML
LINQ to XML Introduction
XElement
XAttribute
Querying Elements
Try This 20-1: Querying XML with LINQ
Additional Element Selection Methods and Properties
Try This 20-2: Querying XML with LINQ, Continued
Creating XML Elements and Attributes
Creating Attributes
Creating Elements
Adding Elements to Existing Documents
Updating XML Elements and Attributes
Deleting XML Elements
XML Serialization and Deserialization
Serialization
Deserialization
Chapter 20 Self Test
21 JSON Handling
JSON Introduction
Json.NET
Creating Dynamic JSON Objects
Dynamic Types
Creating JSON Arrays
Try This 21-1: JSON Object and Array Creation
Dynamic Parsing
Referencing Properties
Referencing Arrays
Serialization
Try This 21-2: Creating JSON Through Serialization
Customizing Property Names During Serialization
Deserialization
Mapping to Custom Property Names During Deserialization
Chapter 21 Self Test
Part V Stand-alone Topics
22 Attributes
.NET Framework Attributes
Try This 22-1: Implementing Attributes Practice
Creating and Implementing Custom Attributes
Inheriting from the Attribute Class
Optional AttributeUsage Attributes
Implementing Custom Attributes
Querying Attributes
Try This 22-2: Implementing and Querying Custom Attributes
Reflection Introduction
Querying Attribute Targets
Chapter 22 Self Test
23 Operator Overloading
Operator Overloading Introduction
Operator Overload Method Requirements
Operators that Can Be Overloaded
Try This 23-1: Creating and Using a * Operator Overload
Try This 23-2: Creating and Using a – Operator Overload
Chapter 23 Self Test
A FoodStore Database Reference
Index
← Prev
Back
Next →
← Prev
Back
Next →