Expert C# 5.0: With the .Net 4.5 Framework

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"

Expert C# 5.0 is a book about getting the best from C#. It's based on the principle that to write good, high-performance, robust applications you need to understand whats going on deep under the hood. If you are already experienced with writing managed applications and want to learn more about how to get the best from the language at an advanced level, then this is the book for you. Expert C# 5.0 discusses the familiar C# language in forensic detail. Examining familiar elements closely to reveal how they really work. Key language features that you are already familiar with, such as Enums, Strings and Collections, are teased apart and examined under the twin microscopes of MSIL (Intermediate Language) and the Windbg debugger to see what's really going on behind the scenes as your code is compiled and passed to the CLR. This unparalleled depth of explanation will help you to become a true master of the C# language and architect better crafted applications that work in the most efficient and reliable way possible. It will also give you the insight you need to rapidly identify and fix the stubborn coding faults that others may be unable to diagnose.

Author(s): Mohammad Rahman
Publisher: Apress
Year: 2012

Language: English
Pages: 612

Expert C# 5.0: with .NET 4.5 Framework
Contents at a Glance
Contents
About the Author
About the Technical Reviewer
Acknowledgments
Chapter 1 Reintroducing C#:-A Detailed Look at the Language We All Know
Square Number Using the C#
Compilation of a C# Program
Jitting a C# Program
Understanding the C# Language
Identifiers
Keywords
Literals
Comments
Types
Array
Variables
Variable Storage
Types of Variables
Parameters
Kinds of Operators
Statements
Namespaces
Class
Types of Classes
Constructor
Field
Methods
Properties
Indexers
Automatically Implemented Properties
Struct
Event
Interfaces
Enum
Delegates
Exception
Summary
Chapter 2 C# Objects in Memory
Memory in .NET Applications
The Stack
The Heap
Value and Reference Types
Instantiating an Object
Boxing and Unboxing
Performance in Boxing and Unboxing Operation
Garbage Collection
Generation 0
Generation 1
Generation 2
Summary
Chapter 3 Parameters
Parameter
Method State Description Table
An Instruction Pointer
An Evaluation Stack
A Local Variable Array
An Argument Array
A Method Info Handle
A Local Memory Pool
A Return State Handle
A Security Descriptor
Value Type
Parameter by Value
Parameter by ref
Reference Type
Parameter by Value
Parameter by ref
Default Parameter Value
Summary
Chapter 4 Methods
Instance and Static Method with this Keyword
Memory Information while Running an Instance Method
Memory Information while Running a Static Method
Anonymous Method
In Compile Time
Extension Method
Internal Work of the Extension Method
Extension Method and Resolution
Extension Method and Custom Class
Summary
Chapter 5 Automatic Property Declaration
Automatic Property
var Implicitly Typed Local Variable
var in Runtime
var in Design Time
Anonymous Type
Summary
Chapter 6 Enum
Enum and .NET
How to Get Names and Values from the Enum
Determining Whether an Item Is Defined
Parsing
Summary
Chapter 7 Delegate
Understanding Delegates
Encapsulating Memory Handling with Delegates
Delegate in .NET
Fields
Internal Work of the Delegate
Func and Action
Func
Action
Summary
Chapter 8 Event
Understanding the Event
Designing a Type with the Event
EventHandler Declaration
Event Argument
Event Handler
Subscriber
Execute the Defined Event
Behind the Scenes
In Compile Time
In Runtime
Summary
Chapter 9 Foreach and Iterator
State Machine
Foreach Statement
Declaration
Internal of the Foreach
Iterators
Iterator Internal
Explore the State Machine d__0
Examine Memory of the State Machine
Summary
Chapter 10 The String Data Type
String in .NET
Instantiation of a String Object
How the CLR Handles String Instantiation
Examining the Memory While the CLR Loads String into the Heap
String Instantiation Using Char Array
How the CLR Handles String Instantiation from Char Array
String and Chaining
Strings Are Immutable
String Concatenation
+ Operator
Concat IEnumerable
Concat Array of Objects
Concat Objects
Concat Strings
StringBuilder
Internal of StringBuilder
Summary
Chapter 11 Collections Explained
Collections in .NET
Array Class
Array Class in .NET
Array Class Members
List
Capacity and Size of the List
List Declaration
Instantiation of the List
Addition Operation in the List
Insert Operation in the List
Deletion Operation in the List
List Class Members
ArrayList
Capacity and Size of the ArrayList in .NET
ArrayList Declaration
Instantiation of the ArrayList
Addition and Insertion Operations in the ArrayList Class
Insert a Range of Items in the ArrayList
Deletion Operation in the ArrayList
ArrayList Class Members
Array vs. ArrayList
Stack
Stack in .NET
Stack Declaration
Instantiation of the Stack
Push Operation in the Stack
Peek and Pop Operation in the Stack
Clear Operation in the Stack
Stack Class Members
Queue
Size of the Queue in .NET
Queue Declaration
Instantiation of the Queue
Enqueue and Dequeue Operation in the Queue
Clear Operation in the Queue
Queue Class Members
Hashtable
Size of the Hashtable in .NET
Hashtable Declaration
Instantiation of the Hashtable
Addition Operation in the Hashtable
Deletion Operation in the Hashtable
Hashtable Class Members
Dictionary
Size of the Dictionary in .NET
Instantiation of the Dictionary
Addition Operation in the Dictionary
Dictionary Look Up
Dictionary Class Members
Summary
Chapter 12 Linq in C#
First Look into Linq in .NET
Extension Method
Lambda Expressions and Expression Trees in Linq
Deferred Execution in Linq
Query Methods in Linq
Partitioning-Based Methods
Concatenation Methods
Ordering Methods
Grouping- and Joining-Based Methods
Set-Based Methods
Aggregation-Based Methods
Quantifier-Based Methods
Element-Based Methods
Generation-Based Methods
Conversion-Based Methods
Miscellaneous Methods
Summary
Chapter 13 Exception Management
What Is an Exception?
Exception and .NET Framework
_Exception Interface
How C# Compiler Handles Exception in Compile Time
Exploring Exception Details in Runtime
Exception Handling in .NET
Exception Handling and Bubble Up
Protected Block
Throw and Rethrow
Stack Overwrite
How the CLR Matches Exception in Runtime
Unhandled Exception
Using Statement
Summary
Chapter 14 Asynchrony
Synchronous and Asynchronous Programming
Asynchronous Programming Using Task
Task Class in .NET
Creation/Wait of the Task
Details About the Task Creation Options in Task
Details About the Status of the Task
Continuation of the Task
Schedule the Task Using the TaskScheduler
ExecutionContext to Capture the Context
Exceptions of the Task
Asynchronous Programming Using Async and Await
The Async Modifier
The Await
Analysis of the Async- and Await-Based Asynchronous Program
Async Behind the Scenes
Async in Compile Time
Async in Runtime
Test Cases
When There Is No Return Type
When There Are Multiple Await Statements in Asynchronous Method
When Async in the User Interface
Task-Based Asynchronous Pattern
Usage of the Cancellation to Cancel a Running Task
Usage of the IProgress and Progress to Show Progress of a Running Task
Combinators
Summary
Chapter 15 Diagnostic Tools in .NET
Windbg and Son of Strike Debugging Extension DLL
Download and Installation
Loading SOS Debugging Extension DLL in Windbg
Use of the SOS Debugging Extension DLL in Windbg
Intermediate Language Disassembler
Download and Installation
How to Use the ILDasm
The .NET Reflector: Source Code Explorer
Download and Installation
The .NET Reflector, ILasm, and ILDasm
CLR Profiler: A Memory Profiler
Download and Installation
Memory Profiling
Summary
Index