Thursday, January 27, 2011

C# 4.0 Tutorial PDF


Programming C# 4.0
Ian Griffiths, Matthew Adams, and Jesse Liberty

Table of Contents
Preface
1. Introducing C#
Why C#? Why .NET?
The .NET Framework Class Library
Language Style
Composability
Managed Code 5
Continuity and the Windows Ecosystem
C# 4.0, .NET 4, and Visual Studio 2010
Summary
2. Basic Programming Techniques
Getting Started
Namespaces and Types
Projects and Solutions
Comments, Regions, and Readability
Bad Comments
XML Documentation Comments
Variables
Variable Types
Expressions and Statements
Assignment Statements
Increment and Decrement Operators
Flow Control with Selection Statements
if Statements
switch and case Statements
Iteration Statements
foreach Statements
for Statements
while and do Statements
Breaking Out of a Loop
Methods
Summary
3. Abstracting Ideas with Classes and Structs
Divide and Conquer
Abstracting Ideas with Methods
Abstracting Ideas with Objects and Classes
Defining Classes
Representing State with Properties
Protection Levels
Initializing with a Constructor
Fields: A Place to Put Data
Fields Can Be Fickle, but const Is Forever
Read-only Fields and Properties
Related Constants with enum
Value Types and Reference Types
Too Many Constructors, Mr. Mozart
Overloading
Overloaded Methods and Default Named Parameters
Object Initializers
Defining Methods
Declaring Static Methods
Static Fields and Properties
Static Constructors
Summary
4. Extensibility and Polymorphism
Association Through Composition and Aggregation
Inheritance and Polymorphism
Replacing Methods in Derived Classes
Hiding Base Members with new
Replacing Methods with virtual and override
Inheritance and Protection
Calling Base Class Methods
Thus Far and No Farther: sealed
Requiring Overrides with abstract
All Types Are Derived from Object
Boxing and Unboxing Value Types
C# Does Not Support Multiple Inheritance of Implementation
C# Supports Multiple Inheritance of Interface
Deriving Interfaces from Other Interfaces
Explicit Interface Implementation
The Last Resort: Checking Types at Runtime
Summary
5. Composability and Extensibility with Delegates
Functional Composition with delegate
Generic Actions with Action<T>
Generic Predicates with Predicate<T>
Using Anonymous Methods
Creating Delegates with Lambda Expressions
Delegates in Properties
Generic Delegates for Functions
Notifying Clients with Events
Exposing Large Numbers of Events
Summary
6. Dealing with Errors
When and How to Fail
Returning Error Values
Debugging with Return Values
Exceptions
Handling Exceptions
When Do finally Blocks Run?
Deciding What to Catch
Custom Exceptions
Summary
7. Arrays and Lists
Arrays
Construction and Initialization
Custom Types in Arrays
Array Members
Array Size
List<T>
Custom Indexers
Finding and Sorting
Collections and Polymorphism
Creating Your Own IEnumerable<T>
Summary
8. LINQ
Query Expressions
Query Expressions Versus Method Calls
Extension Methods and LINQ
let Clauses
LINQ Concepts and Techniques
Delegates and Lambdas
Functional Style and Composition
Deferred Execution
LINQ Operators
Filtering
Ordering
Concatenation
Grouping
Projections
Zipping
Getting Selective
Testing the Whole Collection
Aggregation
Set Operations
Joining
Conversions
Summary
9. Collection Classes
Dictionaries
Common Dictionary Uses
IDictionary<TKey, TValue>
Dictionaries and LINQ
HashSet and SortedSet
Queues
Linked Lists
Stacks
Summary
10. Strings
What Is a String?
The String and Char Types
Literal Strings and Chars
Escaping Special Characters
Formatting Data for Output
Standard Numeric Format Strings
Custom Numeric Format Strings
Dates and Times
Going the Other Way: Converting Strings to Other Types
Composite Formatting with String.Format
Culture Sensitivity
Accessing Characters by Index
Strings Are Immutable
Getting a Range of Characters
Composing Strings
Splitting It Up Again
Upper- and Lowercase
Manipulating Text
Mutable Strings with StringBuilder
Finding and Replacing Content
All Sorts of “Empty” Strings
Trimming Whitespace
Checking Character Types
Encoding Characters
Why Encodings Matter
Encoding and Decoding
Why Represent Strings As Byte Sequences?
Summary
11. Files and Streams
Inspecting Directories and Files
Examining Directories
Manipulating File Paths
Path and the Current Working Directory
Examining File Information
Creating Temporary Files
Deleting Files
Well-Known Folders
Concatenating Path Elements Safely
Creating and Securing Directory Hierarchies
Deleting a Directory
Writing Text Files
Writing a Whole Text File at Once
Writing Text with a StreamWriter
When Files Go Bad: Dealing with Exceptions
Finding and Modifying Permissions
Reading Files into Memory
Streams
Moving Around in a Stream
Writing Data with Streams
Reading, Writing, and Locking Files
FileStream Constructors
Stream Buffers
Setting Permissions During Construction
Setting Advanced Options
Asynchronous File Operations
Isolated Storage
Stores
Reading and Writing Text
Defining “Isolated”
Managing User Storage with Quotas
Managing Isolated Storage
Streams That Aren’t Files
An Adapting Stream: CryptoStream
In Memory Alone: The MemoryStream
Representing Binary As Text with Base64 Encoding
Summary
12. XML
XML Basics (A Quick Review)
Elements
XHTML
X Stands for eXtensible
Creating XML Documents
XML Elements
XML Attributes
Putting the LINQ in LINQ to XML
Searching in XML with LINQ
Searching for a Single Node
Search Axes
Where Clauses
XML Serialization
Customizing XML Serialization Using Attributes
Summary
13. Networking
Choosing a Networking Technology
Web Application with Client-Side Code
.NET Client and .NET Server
.NET Client and External Party Web Service
External Client and .NET Web Service
WCF
Creating a WCF Project
WCF Contracts
WCF Test Client and Host
Hosting a WCF Service
Writing a WCF Client
Bidirectional Communication with Duplex Contracts
HTTP
WebClient
WebRequest and WebResponse
Sockets
IP, IPv6, and TCP
Connecting to Services with the Socket Class
Implementing Services with the Socket Class
Other Networking Features
Summary
14. Databases
The .NET Data Access Landscape
Classic ADO.NET
LINQ and Databases
Non-Microsoft Data Access Technologies
WCF Data Services
Silverlight and Data Access
Databases
The Entity Data Model
Generated Code
Changing the Mapping
Relationships
Inheritance
Queries
LINQ to Entities
Entity SQL
Mixing ESQL and LINQ
The EntityClient ADO.NET Provider
Object Context
Connection Handling
Creating, Updating, and Deleting
Transactions
Optimistic Concurrency
Context and Entity Lifetime
WCF Data Services
Summary
15. Assemblies
.NET Components: Assemblies
References
Writing Libraries
Protection
Naming
Signing and Strong Names
Loading
Loading from the Application Folder
Loading from the GAC
Loading from a Silverlight .xap File
Explicit Loading
Summary
16. Threads and Asynchronous Code
Threads
Threads and the OS Scheduler
The Stack
The Thread Pool
Thread Affinity and Context
Common Thread Misconceptions
Multithreaded Coding Is Hard
Multithreading Survival Strategies
Synchronization Primitives
Monitor
Other Lock Types
Other Coordination Mechanisms
Events
Countdown
BlockingCollection
Asynchronous Programming
The Asynchronous Programming Model
The Event-Based Asynchronous Pattern
Ad Hoc Asynchrony
The Task Parallel Library
Tasks
Cancellation
Error Handling
Data Parallelism
Parallel For and ForEach
PLINQ: Parallel LINQ
Summary
17. Attributes and Reflection
Attributes
Types of Attributes
Custom Attributes
Reflection
Inspecting Metadata
Type Discovery
Reflecting on a Specific Type
Late Binding
Summary
18. Dynamic
Static Versus Dynamic
The Dynamic Style and COM Automation
The dynamic Type
Object Types and dynamic
dynamic in Noninterop Scenarios?
Summary
19. Interop with COM and Win32
Importing ActiveX Controls
Importing a Control in .NET
Interop Assemblies
No PIA
64-bit Versus 32-bit
P/Invoke
Pointers
C# 4.0 Interop Syntax Enhancements
Indexed Properties
Optional ref
Summary
20. WPF and Silverlight
Xaml and Code Behind
Xaml and Objects
Elements and Controls
Layout Panels
Graphical Elements
Controls
User Controls
Control Templates
Styles
The Visual State Manager
Data Binding
Data Templates
Summary
21. Programming ASP.NET Applications
Web Forms Fundamentals
Web Forms Events
Web Forms Life Cycle
Creating a Web Application
Code-Behind Files
Adding Controls
Server Controls
Data Binding
Examining the Code
Adding Controls and Events
Summary
22. Windows Forms
Creating the Application
Adding a Binding Source
Controls
Docking and Anchoring
Data Binding
Event Handling
Summary
Index
Please download here PDF | 7.6 MB

C# Tutorial
Table of Content
C# Tutorial
Audience
Prerequisites
Copyright & Disclaimer Notice
C# Overview
Strong Programming Features of C#
C# Environment
The .Net Framework
Integrated Development Environment (IDE) For C#
Writing C# Programs on Linux or Mac OS
C# Program Structure
C# Hello World Example
Compile & Execute a C# Program:
C# Basic Syntax
The using Keyword
The class Keyword
Comments in C#
Member Variables
Member Functions
Instantiating a Class
Identifiers
C# Keywords
C# Data Types
Value Types
Reference Types
OBJECT TYPE
DYNAMIC TYPE
STRING TYPE
Pointer Types
C# Type Conversion
C# Type Conversion Methods
C# Variables
Variable Declaration in C#
Variable Initialization in C#
Accepting Values from User
Lvalues and Rvalues in C#:
C# Constants and Literals
Integer Literals
Floating-point Literals
Character Constants
String Literals
Defining Constants
C# Operators
Arithmetic Operators
Example
Relational Operators
Example
Logical Operators
Example
Bitwise Operators
Example
Assignment Operators
Example
Misc Operators
Example
Operators Precedence in C#
Example
C# Decision Making
If statement
Syntax:
Flow Diagram:
Example:
If…else statement
Syntax:
Example:
The if...else if...else Statement
Syntax:
Example:
nested if statements
Syntax:
Example:
switch statement
Syntax:
Flow Diagram:
Example:
nested switch statement
Syntax:
Example:
The ? : Operator:
C# Loops
while loop
Syntax:
Flow Diagram:
Example:
for loop
Syntax:
Flow Diagram:
Example:
do…while loop
Syntax:
Flow Diagram:
Example:
nested loops
Syntax:
Example:
Loop Control Statements:
break statement
Syntax:
Flow Diagram:
Example:
continue statement
Syntax:
Flow Diagram:
Example:
The Infinite Loop:
C# Encapsulation
Public Access Specifier
Private Access Specifier
Protected Access Specifier
Internal Access Specifier
Protected Internal Access Specifier
C# Methods
Defining Methods in C#
Example:
Calling Methods in C#
Recursive Method Call
Passing Parameters to a Method
Value parameters
Reference parameters
Output parameters
C# Nullables
The Null Coalescing Operator (??)
C# Arrays
Declaring Arrays
Initializing an Array
Assigning Values to an Array
Accessing Array Elements
Using the foreach Loop
C# Arrays in Detail
Initializing Two-Dimensional Arrays
Accessing Two-Dimensional Array Elements
Methods of the Array Class
Example
C# Strings
Creating a String Object
Properties of the String Class
Methods of the String Class
Examples:
Comparing Strings:
C# Structures
Defining a Structure
Features of C# Structures
Class vs Structure
C# Enums
Declaring enum Variable
Example:
C# Classes
Class Definition
Member Functions and Encapsulation
Constructors in C#
Destructors in C#
Static Members of a C# Class
C# Inheritance
Base and Derived Classes
Base Class Initialization
Multiple Inheritance in C#
C# Polymorphism
Static Polymorphism
Function Overloading
Dynamic Polymorphism
C# Operator Overloading
Implementation of Operator Overloading
Overloadable and Non-Overloadable Operators
Example:
C# Interfaces
Declaring Interfaces
Example
C# Namespaces
Defining a Namespace
The using Keyword
Nested Namespaces
C# Preprocessor Directives
List of Preprocessor Directives in C#
The #define Preprocessor
Conditional Directives
C# Regular Expressions
Constructs for Defining Regular Expressions
Character escapes
Character classes
Anchors
Grouping constructs
Quantifiers
Backreference constructs
Alternation constructs
Substitution
Miscellaneous constructs
The Regex Class
Example 1
Example 2
Example 3
C# Exception Handling
Syntax
Exception Classes in C#
Handling Exceptions
Creating User-Defined Exceptions
Throwing Objects
C# File I/O
C# I/O Classes
The FileStream Class
Example:
Advanced File Operations in C#
The StreamReader Class
Example:
The StreamWriter Class
Example:
The BinaryReader Class
The BinaryWriter Class
Example
The DirectoryInfo Class
The FileInfo Class
Example
C# Attributes
Specifying an Attribute
Predefined Attributes
AttributeUsage:
Conditional
Obsolete
Creating Custom Attributes
Declaring a Custom Attribute
Constructing the Custom Attribute
Applying the Custom Attribute
C# Reflection
Uses of Reflection
Viewing Metadata
Example
C# Properties
Accessors
Example:
Abstract Properties
C# Indexers
Syntax
Use of Indexers
Overloaded Indexers
C# Delegates
Declaring Delegates
Instantiating Delegates
Multicasting of a Delegate
Use of Delegate
C# Events
Using Delegates with Events
Declaring Events
Example 1
Example 2
C# Collections
Various Collection Classes and Their Usage
Methods and Properties of the ArrayList Class
Example:
Example:
Methods and Properties of the SortedList Class
Example:
Methods and Properties of the Stack Class
Example:
Methods and Properties of the Queue Class
Example:
Example:
C# Generics
Features of Generics
Generic Methods
Generic Delegates
C# Anonymous Methods
Syntax for Writing an Anonymous Method
Example:
C# Unsafe Codes
Pointer Variables
Retrieving the Data Value Using a Pointer
Passing Pointers as Parameters to Methods
Accessing Array Elements Using a Pointer
Compiling Unsafe Code
C# Multithreading
Thread Life Cycle
The Main Thread
Commonly Used Properties and Methods of the Thread Class
Creating Threads
Managing Threads
Destroying Threads
Please download here PDF | 2.61 MB
Kindly Bookmark this Post using your favorite Bookmarking service:
Technorati Digg This Stumble Stumble Facebook Twitter

0 komentar:

Post a Comment

 

About Me

My Photo
James Priyono
I'm Just a Blogger, share knowledge and information.
View my complete profile

Recent Comments

| Gudang PDF © 2014. All Rights Reserved | Template Style by My Blogger Tricks .com | Design by Brian Gardner | Back To Top |