Beginning Visual C# 2012 Programming

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

Step-by-step beginner's guide to Visual C# 2012Written for novice programmers who want to learn programming with C# and the .NET framework, this book offers programming basics such as variables, flow control, and object oriented programming. It then moves into web and Windows programming and data access (databases and XML). The authors focus on the tool that beginners use most often to program C#, the Visual C# 2012 development environment in Visual Studio 2012.Puts the spotlight on key beginning level topics with easy-to-follow instructions for Microsoft Visual C# 2012Explores how to program for variables, expressions, flow control, and functionsExplains the debugging process and error handling as well as object oriented programming, and much more "Beginning Microsoft Visual C# 2012 Programming" offers beginners a guide to writing effective programming code following simple step-by-step methods, each followed by the opportunity to try out newly acquired skills.

Author(s): Karli Watson; Jacob Vibe Hammer; Jon Reid; Morgan Skinner; Daniel Kemper; Christian Nagel
Publisher: Wrox Press
Year: 2012

Language: English
Pages: 912

Cover
Contents
Introduction
Part I: The C# Language
Chapter 1: Introducing C#
What Is the .NET Framework?
What's in the .NET Framework?
Writing Applications Using the .NET Framework
CIL and JIT
Assemblies
Managed Code
Garbage Collection
Fitting It Together
Linking
What Is C#?
Applications You Can Write with C#
C# in this Book
Visual Studio 2012
Visual Studio Express 2012 Products
Solutions
Summary
Chapter 2: Writing a C# Program
The Visual Studio 2012 Development Environment
Console Applications
The Solution Explorer
The Properties Window
The Error List Window
Desktop Applications
Summary
Chapter 3: Variables and Expressions
Basic C# Syntax
Basic C# Console Application Structure
Variables
Simple Types
Variable Naming
Naming Conventions
Literal Values
Variable Declaration and Assignment
Expressions
Mathematical Operators
Assignment Operators
Operator Precedence
Namespaces
Summary
Chapter 4: Flow Control
Boolean Logic
Boolean Assignment Operators
Bitwise Operators
Operator Precedence Updated
The goto Statement
Branching
The Ternary Operator
The if Statement
Checking More Conditions Using if Statements
The switch Statement
Looping
do Loops
while Loops
for Loops
Interrupting Loops
Infinite Loops
Summary
Chapter 5: More About Variables
Type Conversion
Implicit Conversions
Explicit Conversions
Explicit Conversions Using the Convert Commands
Complex Variable Types
Enumerations
Defining Enumerations
Structs
Defining Structs
Arrays
Declaring Arrays
foreach Loops
Multidimensional Arrays
Arrays of Arrays
String Manipulation
Summary
Chapter 6: Functions
Defining and Using Functions
Return Values
Parameters
Parameter Matching
Parameter Arrays
Reference and Value Parameters
Out Parameters
Variable Scope
Variable Scope in Other Structures
Parameters and Return Values versus Global Data
The Main( ) Function
Struct Functions
Overloading Functions
Using Delegates
Summary
Chapter 7: Debugging and Error Handling
Debugging in Visual Studio
Debugging in Nonbreak (Normal) Mode
Outputting Debugging Information
Tracepoints
Diagnostics Output Versus Tracepoints
Debugging in Break Mode
Entering Break Mode
Monitoring Variable Content
Stepping Through Code
Immediate and Command Windows
The Call Stack Window
Error Handling
try…catch…finally
Listing and Configuring Exceptions
Notes on Exception Handling
Summary
Chapter 8: Introduction to Object-Oriented Programming
What Is Object-Oriented Programming?
What Is an Object?
Properties and Fields
Methods
Everything's an Object
The Life Cycle of an Object
Constructors
Destructors
Static and Instance Class Members
Static Constructors
Static Classes
OOP Techniques
Interfaces
Disposable Objects
Inheritance
Polymorphism
Interface Polymorphism
Relationships Between Objects
Containment
Collections
Operator Overloading
Events
Reference Types Versus Value Types
OOP in Desktop Applications
Summary
Chapter 9: Defining Classes
Class Definitions in C#
Interface Definitions
System.Object
Constructors and Destructors
Constructor Execution Sequence
OOP Tools in Visual Studio
The Class View Window
The Object Browser
Adding Classes
Class Diagrams
Class Library Projects
Interfaces Versus Abstract Classes
Struct Types
Shallow Copying Versus Deep Copying
Summary
Chapter 10: Defining Class Members
Member Definitions
Defining Fields
Defining Methods
Defining Properties
Adding Members from a Class Diagram
Adding Methods
Adding Properties
Adding Fields
Refactoring Members
Automatic Properties
Additional Class Member Topics
Hiding Base Class Methods
Calling Overridden or Hidden Base Class Methods
The this Keyword
Using Nested Type Definitions
Interface Implementation
Implementing Interfaces in Classes
Explicit Interface Member Implementation
Additional Property Accessors
Partial Class Definitions
Partial Method Definitions
Example Application
Planning the Application
The Card Class
The Deck Class
Writing the Class Library
Adding the Suit and Rank Enumerations
Adding the Card Class
Adding the Deck Class
A Client Application for the Class Library
The Call Hierarchy Window
Summary
Chapter 11: Collections, Comparisons, and Conversions
Collections
Using Collections
Defining Collections
Indexers
Adding a Cards Collection to CardLib
Keyed Collections and IDictionary
Iterators
Iterators and Collections
Deep Copying
Adding Deep Copying to CardLib
Comparisons
Type Comparisons
Boxing and Unboxing
The is Operator
Value Comparisons
Operator Overloading
Adding Operator Overloads to CardLib
The IComparable and IComparer Interfaces
Sorting Collections
Conversions
Overloading Conversion Operators
The as Operator
Summary
Chapter 12: Generics
What Are Generics?
Using Generics
Nullable Types
Operators and Nullable Types
The ?? Operator
The System.Collections.Generic Namespace
List
Sorting and Searching Generic Lists
Dictionary
Modifying CardLib to Use a Generic Collection Class
Defining Generic Types
Defining Generic Classes
The default Keyword
Constraining Types
Inheriting from Generic Classes
Generic Operators
Generic Structs
Defining Generic Interfaces
Defining Generic Methods
Defining Generic Delegates
Variance
Covariance
Contravariance
Summary
Chapter 13: Additional OOP Techniques
The :: Operator and the Global Namespace Qualifier
Custom Exceptions
Adding Custom Exceptions to CardLib
Events
What Is an Event?
Handling Events
Defining Events
Multipurpose Event Handlers
The EventHandler and Generic EventHandler Types
Return Values and Event Handlers
Anonymous Methods
Expanding and Using CardLib
A Card Game Client for CardLib
Attributes
Reading Attributes
Creating Attributes
Summary
Chapter 14: C# Language Enhancements
Initializers
Object Initializers
Collection Initializers
Type Inference
Anonymous Types
Dynamic Lookup
The dynamic Type
IDynamicMetaObjectProvider
Advanced Method Parameters
Optional Parameters
Optional Parameter Values
The OptionalAttribute Attribute
Optional Parameter Order
Named Parameters
Named and Optional Parameter Guidelines
Extension Methods
Lambda Expressions
Anonymous Methods Recap
Lambda Expressions for Anonymous Methods
Lambda Expression Parameters
Lambda Expression Statement Bodies
Lambda Expressions as Delegates and Expression Trees
Lambda Expressions and Collections
Caller Information Attributes
Summary
Part II: Windows Programming
Chapter 15: Basic Desktop Programming
XAML
Separation of Concerns
XAML in Action
Namespaces
Code-Behind Files
The Playground
WPF Controls
Properties
Dependency Properties
Attached Properties
Events
Handling Events
Routed Events
Routed Commands
Control Types
Control Layout
Stack Order
Alignment, Margins, Padding, and Dimensions
Border
Canvas
DockPanel
StackPanel
WrapPanel
Grid
The Game Client
The About Window
Designing the User Interface
The Image Control
The Label Control
The TextBlock Control
The Button Control
The Options Window
The TextBox Control
The CheckBox Control
The RadioButton Control
The ComboBox Control
The TabControl
Handling Events in the Options Window
Data Binding
The DataContext
Binding to Local Objects
Static Binding to External Objects
Dynamic Binding to External Objects
Starting a Game
The ListBox Control
Summary
Chapter 16: Advanced Desktop Programming
The Main Window
The Menu Control
Routed Commands with Menus
Creating and Styling Controls
Styles
Templates
Value Converters
The IValueConverter Interface
ValueConversionAttribute
Triggers
Animations
Timelines without Key Frames
Timelines with Key Frames
WPF User Controls
Implementing Dependency Properties
Putting It All Together
Refactoring the Domain Model
The View Models
Completing the Game
Summary
Chapter 17: Windows Store Apps
Getting Started
Windows 8 Developer License
How to Get the License
Windows Store Apps versus Desktop Applications
Developing Windows Store Apps
View Modes
Full-Screen Mode
Snapped Mode
Fill Mode
Screen Orientation
The Missing Caption Bar
Menus and Toolbars
The App Bar
Charms
Tiles and Badges
App Lifetime
Lock Screen Apps
App Development
WPF and Windows Store App XAML Differences
Namespace Changes
Effects
Opacity Mask
Style Triggers
Commands
Templates and Pages
Blank Page
Basic Page
Grouped Items and Group Details Pages
Item Details Page
Items and Split Pages
Sandboxed Apps
Disk Access
Serialization, Streams, and Async Programming
Navigation Between Pages
Managing State
Converting KarliCards, Part 1
Creating the CardLib Project
Converting the View Models
Visual Changes
Drop Shadow and Opacity Masks
Style Triggers
Converting User Controls
Common Elements of Windows Store Apps
The AppBar Control
The Settings Panel
Tiles, Badges, and Splash Screens
Converting KarliCards, Part 2
The Windows Store
Checking the Store Requirements
Summary
Chapter 18: Deploying Desktop Applications
Deployment Overview
ClickOnce Deployment
Implementing ClickOnce Deployment
Installing the Application with ClickOnce
Creating and Using Updates of the Application
InstallShield Limited Edition
The Project Assistant
Step 1: Application Information
Step 2: Installation Requirements
Step 3: Installation Architecture
Step 4: Application Files
Step 5: Application Shortcuts
Step 6: Application Registry
Step 7: Installation Interview
Summary
Part III: Web Programming
Chapter 19: ASP.NET Web Programming
Overview of Web Applications
ASP.NET Runtime
Creating a Simple Page
Server Controls
ASP.NET Postback
ASP.NET AJAX Postback
Input Validation
State Management
Client-Side State Management
View State
Cookie
Server-Side State Management
Session
Application
Cache
Styles
Master Pages
Site Navigation
Authentication and Authorization
Authentication Configuration
Using Security Controls
Reading from and Writing to a SQL Server Database
Summary
Chapter 20: Deploying Web Applications
Internet Information Services
IIS Configuration
Copying a Website
Publishing a Web Application
Summary
Part IV: Data Access
Chapter 21: File System Data
Streams
The Classes for Input and Output
The File and Directory Classes
The FileInfo Class
The DirectoryInfo Class
Path Names and Relative Paths
The FileStream Object
File Position
Reading Data
Writing Data
The StreamWriter Object
The StreamReader Object
Reading Data
Delimited Files
Asynchronous File Access
Reading and Writing Compressed Files
Serialized Objects
Monitoring the File System
Summary
Chapter 22: XML
XML Documents
XML Elements
Attributes
The XML Declaration
The Structure of an XML Document
XML Namespaces
Well-Formed and Valid XML
Validating XML Documents
Schemas
The XSD dialog box shown in the XmlDocument Class
Using XML in Your Application
XML Document Object Model
The XmlDocument Class
The XmlElement Class
Changing the Values of Nodes
Selecting Nodes
XPath
Summary
Chapter 23: Introduction to LINQ
First LINQ Query
Declaring a Variable for Results Using the var Keyword
Specifying the Data Source: from Clause
Specify Condition: where Clause
Selecting Items: select Clause
Finishing Up: Using the foreach Loop
Deferred Query Execution
Using the LINQ Method Syntax
LINQ Extension Methods
Query Syntax versus Method Syntax
Ordering Query Results
Understanding the orderby Clause
Ordering Using Method Syntax
Querying a Large Data Set
Using Aggregate Operators
Querying Complex Objects
Projection: Creating New Objects in Queries
Projection: Method Syntax
Using the Select Distinct Query
Using the Any and All Methods
Ordering by Multiple Levels
Multi-Level Ordering Method Syntax: ThenBy
Using Group Queries
Using Take and Skip
Using First and FirstOrDefault
Using the LINQ Set Operators
Using Joins
Summary
Chapter 24: Applying LINQ
LINQ Varieties
Using LINQ with Databases
Installing SQL Server and the Northwind Sample Data
Installing SQL Server Express
Installing the Northwind Sample Database
First LINQ to Database Query
Navigating Database Relationships
Using LINQ with XML
LINQ to XML Functional Constructors
Constructing XML Element Text with Strings
Saving and Loading an XML Document
Loading XML from a String
Contents of a Saved XML Document
Working with XML Fragments
Generating XML from Databases
How to Query an XML Document
Using LINQ to XML Query Members
Elements( )
Descendants( )
Attributes( )
Summary
Part V: Additional Techniques
Chapter 25: Windows Communication Foundation
What Is WCF?
WCF Concepts
WCF Communication Protocols
Addresses, Endpoints, and Bindings
Contracts
Message Patterns
Behaviors
Hosting
WCF Programming
The WCF Test Client
Defining WCF Service Contracts
Data Contracts
Service Contracts
Operation Contracts
Message Contracts
Fault Contracts
Self-Hosted WCF Services
Summary
Chapter 26: Windows Workflow Foundation
Hello World
Workflows and Activities
If Activity
While Activity
Sequence Activity
Arguments and Variables
Custom Activities
Workflow Extensions
Activity Validation
Activity Designers
Summary
Appendix A: Exercise Solutions
Index
Advertisement