38,99 €
Intermediate to advanced technique coverage, updated for C# 2012 and .NET 4.5 This guide is geared towards experienced programmers looking to update and enhance their skills in writing Windows applications, web apps, and Metro apps with C# and .NET 4.5. Packed with information about intermediate and advanced features, this book includes everything professional developers need to know about C# and putting it to work. * Covers challenging .NET features including Language Integrated Query (LINQ), LINQ to SQL, LINQ to XML, WCF, WPF, Workflow, and Generics * Puts the new Async keyword to work and features refreshers on .NET architecture, objects, types, inheritance, arrays, operators, casts, delegates, events, strings, regular expressions, collections, and memory management * Explores new options and interfaces presented by Windows 8 development, WinRT, and Metro style apps * Includes traditional Windows forms programming, ASP.NET web programming with C#, and working in Visual Studio 2012 with C# Professional C# 2012 and .NET 4.5 is a comprehensive guide for experienced programmers wanting to maximize these technologies.
Sie lesen das E-Book in den Legimi-Apps auf:
Seitenzahl: 2528
Veröffentlichungsjahr: 2012
CONTENTS
Part I: The C# Language
Chapter 1: .NET Architecture
The Relationship of C# to .NET
The Common Language Runtime
A Closer Look at Intermediate Language
Assemblies
.NET Framework Classes
Namespaces
Creating .NET Applications Using C#
The Role of C# in the .NET Enterprise Architecture
Summary
Chapter 2: Core C#
Fundamental C#
Your First C# Program
Variables
Predefined Data Types
Flow Control
Enumerations
Namespaces
The Main() Method
More on Compiling C# Files
Console I/O
Using Comments
The C# Preprocessor Directives
C# Programming Guidelines
Summary
Chapter 3: Objects and Types
Creating and Using Classes
Classes and Structs
Classes
Anonymous Types
Structs
Weak References
Partial Classes
Static Classes
The Object Class
Extension Methods
Summary
Chapter 4: Inheritance
Inheritance
Types of Inheritance
Implementation Inheritance
Modifiers
Interfaces
Summary
Chapter 5: Generics
Generics Overview
Creating Generic Classes
Generics Features
Generic Interfaces
Generic Structs
Generic Methods
Summary
Chapter 6: Arrays and Tuples
Multiple Objects of the Same and Different Types
Simple Arrays
Multidimensional Arrays
Jagged Arrays
Array Class
Arrays as Parameters
Enumerations
Tuples
Structural Comparison
Summary
Chapter 7: Operators and Casts
Operators and Casts
Operators
Type Safety
Comparing Objects for Equality
Operator Overloading
User-Defined Casts
Summary
Chapter 8: Delegates, Lambdas, and Events
Referencing Methods
Delegates
Lambda Expressions
Events
Summary
Chapter 9: Strings and Regular Expressions
Examining System.String
Regular Expressions
Summary
Chapter 10: Collections
Overview
Collection Interfaces and Types
Lists
Queues
Stacks
Linked Lists
Sorted List
Dictionaries
Sets
Observable Collections
Bit Arrays
Concurrent Collections
Performance
Summary
Chapter 11: Language Integrated Query
LINQ Overview
Standard Query Operators
Parallel LINQ
Expression Trees
LINQ Providers
Summary
Chapter 12: Dynamic Language Extensions
Dynamic Language Runtime
The Dynamic Type
Hosting the DLR ScriptRuntime
DynamicObject and ExpandoObject
Summary
Chapter 13: Asynchronous Programming
Why Asynchronous Programming Is Important
Asynchronous Patterns
Foundation of Asynchronous Programming
Error Handling
Cancellation
Summary
Chapter 14: Memory Management and Pointers
Memory Management
Memory Management Under the Hood
Freeing Unmanaged Resources
Unsafe Code
Summary
Chapter 15: Reflection
Manipulating and Inspecting Code at Runtime
Custom Attributes
Using Reflection
Summary
Chapter 16: Errors and Exceptions
Introduction
Exception Classes
Catching Exceptions
User-Defined Exception Classes
Caller Information
Summary
Part II: Visual Studio
Chapter 17: Visual Studio 2012
Working with Visual Studio 2012
Creating a Project
Exploring and Coding a Project
Building a Project
Debugging Your Code
Refactoring Tools
Architecture Tools
Analyzing Applications
Unit Tests
Windows 8, WCF, WF, and More
Summary
Chapter 18: Deployment
Deployment as Part of the Application Life Cycle
Planning for Deployment
Traditional Deployment
ClickOnce
Web Deployment
Windows 8 Apps
Summary
Part III: Foundation
Chapter 19: Assemblies
What are Assemblies?
Application Domains
Shared Assemblies
Configuring .NET Applications
Versioning
Sharing Assemblies Between Different Technologies
Summary
Chapter 20: Diagnostics
Diagnostics Overview
Code Contracts
Tracing
Event Logging
Performance Monitoring
Summary
Chapter 21: Tasks, Threads, and Synchronization
Overview
Parallel Class
Tasks
Cancellation Framework
Thread Pools
The Thread Class
Threading Issues
Synchronization
Timers
Data Flow
Summary
Chapter 22: Security
Introduction
Authentication and Authorization
Encryption
Access Control to Resources
Code Access Security
Distributing Code Using Certificates
Summary
Chapter 23: Interop
.NET and COM
Using a COM Component from a .NET Client
Using a .NET Component from a COM Client
Platform Invoke
Summary
Chapter 24: Manipulating Files and The Registry
File and the Registry
Managing the File System
Moving, Copying, and Deleting Files
Reading and Writing to Files
Mapped Memory Files
Reading Drive Information
File Security
Reading and Writing to the Registry
Reading and Writing to Isolated Storage
Summary
Chapter 25: Transactions
Introduction
Overview
Database and Entity Classes
Traditional Transactions
System.Transactions
Dependent Transactions
Isolation Level
Custom Resource Managers
File System Transactions
Summary
Chapter 26: Networking
Networking
The WebClient Class
WebRequest and WebResponse Classes
Displaying Output As an HTML Page
Utility Classes
Lower-Level Protocols
Summary
Chapter 27: Windows Services
What Is a Windows Service?
Windows Services Architecture
Creating a Windows Service Program
Monitoring and Controlling Windows Services
Troubleshooting and Event Logging
Summary
Chapter 28: Localization?
Global Markets
Namespace System.Globalization
Resources
Windows Forms Localization Using Visual Studio
Localization with ASP.NET Web Forms
Localization with WPF
A Custom Resource Reader
Creating Custom Cultures
Localization with Windows Store Apps
Summary
Chapter 29: Core XAML
Uses of XAML
XAML Foundation
Dependency Properties
Bubbling and Tunneling Events
Attached Properties
Markup Extensions
Reading and Writing XAML
Summary
Chapter 30: Managed Extensibility Framework
Introduction
MEF Architecture
Defining Contracts
Exporting Parts
Importing Parts
Containers and Export Providers
Catalogs
Summary
Chapter 31: Windows Runtime
Overview
Windows Runtime Components
Windows 8 Apps
The Life Cycle of Applications
Application Settings
Webcam Capabilities
Summary
Part IV: Data
Chapter 32: Core ADO.NET
ADO.NET Overview
Using Database Connections
Commands
Fast Data Access: The Data Reader
Asynchronous Data Access: Using Task and Await
Managing Data and Relationships: The DataSet Class
XML Schemas: Generating Code with XSD
Populating a DataSet
Persisting DataSet Changes
Working with ADO.NET
Summary
Chapter 33: ADO.NET Entity Framework
Programming with the Entity Framework
Entity Framework Mapping
Entities
Object Context
Relationships
Querying Data
Writing Data to the Database
Using POCO Objects
Using the Code First Programming Model
Summary
Chapter 34: Manipulating XML
XML
XML Standards Support in .NET
Introducing the System.Xml Namespace
Using System.Xml Classes
Reading and Writing Streamed XML
Using the DOM in .NET
Using XPathNavigators
XML and ADO.NET
Serializing Objects in XML
LINQ to XML and .NET
Working with Different XML Objects
Using LINQ to Query XML Documents
More Query Techniques for XML Documents
Summary
Part V: Presentation
Chapter 35: Core WPF
Understanding WPF
Shapes
Geometry
Transformation
Brushes
Controls
Layout
Styles and Resources
Triggers
Templates
Animations
Visual State Manager
3-D
Summary
Chapter 36: Business Applications with WPF
Introduction
Menu and Ribbon Controls
Commanding
Data Binding
TreeView
DataGrid
Summary
Chapter 37: Creating Documents with WPF
Introduction
Text Elements
Flow Documents
Fixed Documents
XPS Documents
Printing
Summary
Chapter 38: Windows Store APPS
Overview
Windows 8 Modern UI Design
Sample Application Core Functionality
App Bars
Launching and Navigation
Layout Changes
Storage
Pickers
Sharing Contract
Tiles
Summary
Chapter 39: Core ASP.NET
.NET Frameworks for Web Applications
Web Technologies
Hosting and Configuration
Handlers and Modules
Global Application Class
Request and Response
State Management
Membership and Roles
Summary
Chapter 40: ASP.NET Web Forms
Overview
ASPX Page Model
Master Pages
Navigation
Validating User Input
Accessing Data
Security
Ajax
Summary
Chapter 41: ASP.NET MVC
ASP.NET MVC Overview
Defining Routes
Creating Controllers
Creating Views
Submitting Data from the Client
HTML Helpers
Creating a Data-Driven Application
Action Filters
Authentication and Authorization
ASP.NET Web API
Summary
Chapter 42: ASP.NET Dynamic Data
Overview
Creating Dynamic Data Web Applications
Customizing Dynamic Data Websites
Summary
Part VI: Communication
Chapter 43: Windows Communication Foundation
WCF Overview
Creating a Simple Service and Client
Contracts
Service Behaviors
Binding
Hosting
Clients
Duplex Communication
Routing
Summary
Chapter 44: WCF Data Services
Overview
Custom Hosting with CLR Objects
HTTP Client Application
Queries with URLs
Using WCF Data Services with the ADO.NET Entity Framework
Summary
Chapter 45: Windows Workflow Foundation
A Workflow Overview
Hello World
Activities
Custom Activities
Workflows
Summary
Chapter 46: Peer-to-Peer Networking
Peer-to-Peer Networking Overview
Peer Name Resolution Protocol (PNRP)
Building P2P Applications
Summary
Chapter 47: Message Queuing
Overview
Message Queuing Products
Message Queuing Architecture
Message Queuing Administrative Tools
Programming Message Queuing
Course Order Application
Receiving Results
Transactional Queues
Message Queuing with WCF
Message Queue Installation
Summary
Introduction
Advertisements
CHAPTER 1:
.NET Architecture
CHAPTER 2:
Core C#
CHAPTER 3:
Objects and Types
CHAPTER 4:
Inheritance
CHAPTER 5:
Generics
CHAPTER 6:
Arrays and Tuples
CHAPTER 7:
Operators and Casts
CHAPTER 8:
Delegates, Lambdas, and Events
CHAPTER 9:
Strings and Regular Expressions
CHAPTER 10:
Collections
CHAPTER 11:
Language Integrated Query
CHAPTER 12:
Dynamic Language Extensions
CHAPTER 13:
Asynchronous Programming
CHAPTER 14:
Memory Management and Pointers
CHAPTER 15:
Reflection
CHAPTER 16:
Errors and Exceptions
WHAT’S IN THIS CHAPTER?
Compiling and running code that targets .NET
Advantages of Microsoft Intermediate Language (MSIL)
Value and reference types
Data typing
Understanding error handling and attributes
Assemblies, .NET base classes, and namespaces
WROX.COM CODE DOWNLOADS FOR THIS CHAPTER
There are no code downloads for this chapter.
This book emphasizes that the C# language must be considered in parallel with the .NET Framework, rather than viewed in isolation. The C# compiler specifically targets .NET, which means that all code written in C# always runs within the .NET Framework. This has two important consequences for the C# language:
Because of this dependence, you must gain some understanding of the architecture and methodology of .NET before you begin C# programming, which is the purpose of this chapter.
C# is a programming language newly designed for .NET. and is significant in two respects:
It is specifically designed and targeted for use with Microsoft’s .NET Framework (a feature-rich platform for the development, deployment, and execution of distributed applications).
It is a language based on the modern object-oriented design methodology, and when designing it Microsoft learned from the experience of all the other similar languages that have been around since object-oriented principles came to prominence 20 years ago.
C# is a language in its own right. Although it is designed to generate code that targets the .NET environment, it is not part of .NET. Some features are supported by .NET but not by C#, and you might be surprised to learn that some features of the C# language are not supported by .NET (for example, some instances of operator overloading).
However, because the C# language is intended for use with .NET, you must understand this Framework if you want to develop applications in C# effectively. Therefore, this chapter takes some time to peek underneath the surface of .NET.
Central to the .NET Framework is its runtime execution environment, known as the Common Language Runtime (CLR) or the .NET runtime. Code running under the control of the CLR is often termed managed code.
However, before it can be executed by the CLR, any source code that you develop (in C# or some other language) needs to be compiled. Compilation occurs in two steps in .NET:
This two-stage compilation process is important because the existence of the Microsoft Intermediate Language is the key to providing many of the benefits of .NET.
IL shares with Java byte code the idea that it is a low-level language with a simple syntax (based on numeric codes rather than text), which can be quickly translated into native machine code. Having this well-defined universal syntax for code has significant advantages: platform independence, performance improvement, and language interoperability.
First, platform independence means that the same file containing byte code instructions can be placed on any platform; at runtime, the final stage of compilation can then be easily accomplished so that the code can run on that particular platform. In other words, by compiling to IL you obtain platform independence for .NET in much the same way as compiling to Java byte code gives Java platform independence.
The platform independence of .NET is only theoretical at present because, at the time of writing, a complete implementation of .NET is available only for Windows. However, a partial, cross-platform implementation is available (see, for example, the Mono project, an effort to create an open source implementation of .NET, at www.go-mono.com).
Although previously compared to Java, IL is actually a bit more ambitious than Java byte code. IL is always Just-in-Time compiled (known as JIT compilation), whereas Java byte code was often interpreted. One of the disadvantages of Java was that, on execution, the process to translate from Java byte code to native executable resulted in a loss of performance (with the exception of more recent cases in which Java is JIT compiled on certain platforms).
Instead of compiling the entire application at one time (which could lead to a slow startup time), the JIT compiler simply compiles each portion of code as it is called (just in time). When code has been compiled once, the resultant native executable is stored until the application exits so that it does not need to be recompiled the next time that portion of code is run. Microsoft argues that this process is more efficient than compiling the entire application code at the start because of the likelihood that large portions of any application code will not actually be executed in any given run. Using the JIT compiler, such code can never be compiled.
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!