1. Trang chủ
  2. » Công Nghệ Thông Tin

programming c# 5.0

884 2K 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Cấu trúc

  • Copyright

  • Table of Contents

  • Preface

    • Who This Book Is For

    • Conventions Used in This Book

    • Using Code Examples

    • Safari® Books Online

    • How to Contact Us

    • Acknowledgments

  • Chapter 1. Introducing C#

    • Why C#?

    • Why Not C#?

    • C#’s Defining Features

      • Managed Code and the CLR

      • Generality Trumps Specialization

      • Asynchronous Programming

    • Visual Studio

    • Anatomy of a Simple Program

      • Adding a Project to an Existing Solution

      • Referencing One Project from Another

      • Writing a Unit Test

      • Namespaces

      • Classes

      • Program Entry Point

      • Unit Tests

    • Summary

  • Chapter 2. Basic Coding in C#

    • Local Variables

      • Scope

    • Statements and Expressions

      • Statements

      • Expressions

    • Comments and Whitespace

    • Preprocessing Directives

      • Compilation Symbols

      • #error and #warning

      • #line

      • #pragma

      • #region and #endregion

    • Intrinsic Data Types

      • Numeric Types

      • Booleans

      • Strings and Characters

      • Object

    • Operators

    • Flow Control

      • Boolean Decisions with if Statements

      • Multiple Choice with switch Statements

      • Loops: while and do

      • C-Style for Loops

      • Collection Iteration with foreach Loops

    • Summary

  • Chapter 3. Types

    • Classes

      • Static Members

      • Static Classes

      • Reference Types

    • Structs

      • When to Write a Value Type

    • Members

      • Fields

      • Constructors

      • Methods

      • Properties

      • Indexers

      • Operators

      • Events

      • Nested Types

    • Interfaces

    • Enums

    • Other Types

      • Anonymous Types

    • Partial Types and Methods

    • Summary

  • Chapter 4. Generics

    • Generic Types

    • Constraints

      • Type Constraints

      • Reference Type Constraints

      • Value Type Constraints

      • Multiple Constraints

    • Zero-Like Values

    • Generic Methods

      • Type Inference

    • Inside Generics

    • Summary

  • Chapter 5. Collections

    • Arrays

      • Array Initialization

      • Variable Argument Count with the params Keyword

      • Searching and Sorting

      • Multidimensional Arrays

      • Copying and Resizing

    • List<T>

    • List and Sequence Interfaces

    • Implementing Lists and Sequences

      • Iterators

      • Collection<T>

      • ReadOnlyCollection<T>

    • Dictionaries

      • Sorted Dictionaries

    • Sets

    • Queues and Stacks

    • Linked Lists

    • Concurrent Collections

    • Tuples

    • Summary

  • Chapter 6. Inheritance

    • Inheritance and Conversions

    • Interface Inheritance

    • Generics

      • Covariance and Contravariance

    • System.Object

      • The Ubiquitous Methods of object

    • Accessibility and Inheritance

    • Virtual Methods

      • Abstract Methods

    • Sealed Methods and Classes

    • Accessing Base Members

    • Inheritance and Construction

    • Special Base Types

    • Summary

  • Chapter 7. Object Lifetime

    • Garbage Collection

      • Determining Reachability

      • Accidentally Defeating the Garbage Collector

      • Weak References

      • Reclaiming Memory

      • Garbage Collector Modes

      • Accidentally Defeating Compaction

      • Forcing Garbage Collections

    • Destructors and Finalization

      • Critical Finalizers

    • IDisposable

      • Optional Disposal

    • Boxing

      • Boxing Nullable<T>

    • Summary

  • Chapter 8. Exceptions

    • Exception Sources

      • Exceptions from APIs

      • Exceptions from Your Code

      • Failures Detected by the Runtime

    • Handling Exceptions

      • Exception Objects

      • Multiple catch Blocks

      • Nested try Blocks

      • finally Blocks

    • Throwing Exceptions

      • Rethrowing Exceptions

      • Failing Fast

    • Exception Types

      • Custom Exceptions

    • Unhandled Exceptions

      • Debugging and Exceptions

    • Asynchronous Exceptions

    • Summary

  • Chapter 9. Delegates, Lambdas, and Events

    • Delegate Types

      • Creating a Delegate

      • Multicast Delegates

      • Invoking a Delegate

      • Common Delegate Types

      • Type Compatibility

      • Behind the Syntax

    • Inline Methods

      • Captured Variables

      • Lambdas and Expression Trees

    • Events

      • Standard Event Delegate Pattern

      • Custom Add and Remove Methods

      • Events and the Garbage Collector

      • Events Versus Delegates

    • Delegates Versus Interfaces

    • Summary

  • Chapter 10. LINQ

    • Query Expressions

      • How Query Expressions Expand

      • Supporting Query Expressions

    • Deferred Evaluation

    • LINQ, Generics, and IQueryable<T>

    • Standard LINQ Operators

      • Filtering

      • Select

      • SelectMany

      • Ordering

      • Containment Tests

      • Specific Items and Subranges

      • Aggregation

      • Set Operations

      • Whole-Sequence, Order-Preserving Operations

      • Grouping

      • Joins

      • Conversion

    • Sequence Generation

    • Other LINQ Implementations

      • Entity Framework

      • LINQ to SQL

      • WCF Data Services Client

      • Parallel LINQ (PLINQ)

      • LINQ to XML

      • Reactive Extensions

    • Summary

  • Chapter 11. Reactive Extensions

    • Rx and .NET Versions

    • Fundamental Interfaces

      • IObserver<T>

      • IObservable<T>

    • Publishing and Subscribing with Delegates

      • Creating an Observable Source with Delegates

      • Subscribing to an Observable Source with Delegates

    • Sequence Builders

      • Empty

      • Never

      • Return

      • Throw

      • Range

      • Repeat

      • Generate

    • LINQ Queries

      • Grouping Operators

      • Join Operators

      • SelectMany Operator

      • Aggregation and Other Single-Value Operators

      • Concat Operator

    • Rx Query Operators

      • Merge

      • Windowing Operators

      • The Scan Operator

      • The Amb Operator

      • DistinctUntilChanged

    • Schedulers

      • Specifying Schedulers

      • Built-in Schedulers

    • Subjects

      • Subject<T>

      • BehaviorSubject<T>

      • ReplaySubject<T>

      • AsyncSubject<T>

    • Adaptation

      • IEnumerable<T>

      • .NET Events

      • Asynchronous APIs

    • Timed Operations

      • Interval

      • Timer

      • Timestamp

      • TimeInterval

      • Throttle

      • Sample

      • Timeout

      • Windowing Operators

      • Delay

      • DelaySubscription

    • Summary

  • Chapter 12. Assemblies

    • Visual Studio and Assemblies

    • Anatomy of an Assembly

      • .NET Metadata

      • Resources

      • Multifile Assemblies

      • Other PE Features

    • Type Identity

    • Loading Assemblies

      • Explicit Loading

      • The Global Assembly Cache

    • Assembly Names

      • Strong Names

      • Version

      • Culture

      • Processor Architecture

    • Portable Class Libraries

    • Packaged Deployment

      • Windows 8 UI–Style Apps

      • ClickOnce and XBAP

      • Silverlight and Windows Phone Apps

    • Protection

    • Summary

  • Chapter 13. Reflection

    • Reflection Types

      • Assembly

      • Module

      • MemberInfo

      • Type and TypeInfo

      • MethodBase, ConstructorInfo, and MethodInfo

      • ParameterInfo

      • FieldInfo

      • PropertyInfo

      • EventInfo

    • Reflection Contexts

    • Summary

  • Chapter 14. Dynamic Typing

    • The dynamic Type

    • dynamic and Interoperability

      • Silverlight and Scriptable Objects

      • Dynamic .NET Languages

    • Inside Dynamic

      • Restrictions on the dynamic Type

      • Custom Dynamic Objects

      • ExpandoObject

    • Limitations of dynamic

    • Summary

  • Chapter 15. Attributes

    • Applying Attributes

      • Attribute Targets

      • Compiler-Handled Attributes

      • CLR-Handled Attributes

    • Defining and Consuming Custom Attributes

      • Attribute Type

      • Retrieving Attributes

    • Summary

  • Chapter 16. Files and Streams

    • The Stream Class

      • Position and Seeking

      • Flushing

      • Copying

      • Length

      • Disposal

      • Asynchronous Operation

      • Concrete Stream Types

    • Windows 8 and IRandomAccessStream

    • Text-Oriented Types

      • TextReader and TextWriter

      • Concrete Reader and Writer Types

      • Encoding

    • Files and Directories

      • FileStream Class

      • File Class

      • Directory Class

      • Path Class

      • FileInfo, DirectoryInfo, and FileSystemInfo

      • Known Folders

    • Serialization

      • BinaryReader and BinaryWriter

      • CLR Serialization

      • Data Contract Serialization

      • XmlSerializer

    • Summary

  • Chapter 17. Multithreading

    • Threads

      • Threads, Variables, and Shared State

      • The Thread Class

      • The Thread Pool

      • Thread Affinity and SynchronizationContext

    • Synchronization

      • Monitors and the lock Keyword

      • SpinLock

      • Reader/Writer Locks

      • Event Objects

      • Barrier

      • CountdownEvent

      • Semaphores

      • Mutex

      • Interlocked

      • Lazy Initialization

      • Other Class Library Concurrency Support

    • Tasks

      • The Task and Task<T> Classes

      • Continuations

      • Schedulers

      • Error Handling

      • Custom Threadless Tasks

      • Parent/Child Relationships

      • Composite Tasks

    • Other Asynchronous Patterns

    • Cancellation

    • Parallelism

      • The Parallel Class

      • Parallel LINQ

      • TPL Dataflow

    • Summary

  • Chapter 18. Asynchronous Language Features

    • Asynchronous Keywords: async and await

      • Execution and Synchronization Contexts

      • Multiple Operations and Loops

      • Returning a Task

      • Applying async to Nested Methods

    • The await Pattern

    • Error Handling

      • Validating Arguments

      • Singular and Multiple Exceptions

      • Concurrent Operations and Missed Exceptions

    • Summary

  • Chapter 19. XAML

    • XAML-Based Frameworks

      • WPF

      • Silverlight

      • Windows Phone 7

      • Windows Runtime and Windows 8 UI–Style Apps

    • XAML Basics

      • XAML and XML Namespaces

      • Generated Classes and Codebehind

      • Child Elements

      • Property Elements

      • Event Handling

      • Threading

    • Layout

      • Properties

      • Panels

      • ScrollViewer

      • Layout Events

    • Controls

      • Content Controls

      • Slider and ScrollBar Controls

      • Progress Controls

      • List Controls

      • Control Templates

      • UserControls

    • Text

      • Displaying Text

      • Editing Text

    • Data Binding

      • Data Templates

    • Graphics

      • Shapes

      • Bitmaps

      • Media

    • Styles

    • Summary

  • Chapter 20. ASP.NET

    • Razor

      • Expressions

      • Flow Control

      • Code Blocks

      • Explicitly Indicated Content

      • Page Classes and Objects

      • Using Other Components

      • Layout Pages

      • Start Pages

    • Web Forms

      • Server-Side Controls

      • Expressions

      • Code Blocks

      • Standard Page Objects

      • Page Classes and Objects

      • Using Other Components

      • Master Pages

    • MVC

      • Typical MVC Project Layout

      • Writing Models

      • Writing Views

      • Writing Controllers

      • Handling Additional Input

      • Generating Action Links

    • Routing

    • Summary

  • Chapter 21. Interoperability

    • Calling Native Code

      • Marshaling

      • 32-bit and 64-bit

      • Safe Handles

      • Security

    • Platform Invoke

      • Calling Convention

      • Text Handling

      • Entry Point Name

      • COM-Style Return Values

      • Win32 Error Handling

    • COM

      • RCW Lifetime

      • Metadata

      • Scripting

    • Windows Runtime

      • Metadata

      • Windows Runtime Types

      • Buffers

    • Unsafe Code

    • C++/CLI and the Component Extensions

    • Summary

  • Index

  • About the Author

Nội dung

[...]... to C# its support for asynchronous programming It has always been possible to use asynchronous APIs in C#, but in the past, this tended to involve convoluted code In C# 5.0, you can write asynchronous code that looks almost exactly like normal code, so instead of adding weight to the language, this new asynchronous programming supso instead of adding weight to the language, this new asynchronous programming. .. slightly anachronistic curiosity C# s Defining Features | 9 That said, C# 5.0 has a new feature that looks relatively specialized In fact, it has only one purpose However, it’s an important purpose Asynchronous Programming The most significant new feature in C# 5.0 is support for asynchronous programThe most significant new feature in C# 5.0 is support for asynchronous program ming .NET has always offered... (http://www.mono-project.com/) provides tools for building C# applications that run on Linux, Mac OS X, iOS, and Android Why C#? Although there are many ways you can use C#, other languages are always an option Why might you choose C# over them? It will depend on what you need to do, and what you like and dislike in a programming language I find that C# provides considerable power and flexibility, and works... Introducing C# Although C# s close connection with the runtime is one of its main defining features, it’s not the only one Visual Basic has a similar connection with the CLR, but C# is distinguished from Visual Basic by more than just syntax: it also has a somewhat different philosophy Generality Trumps Specialization C# favors general-purpose language features over specialized ones Over the years, MiC# favors... Introducing C# choice will not come down to language features It is more likely to be driven by the expertise you have in house If you have a development shop full of Ruby experts, choosing C# for your next web application might not be the most effective use of the available talent So not every project will use C# But since you’ve read this far, presumably you’re still considering using C# So what is C# like?... programming idioms a language offers, it also needs to provide full and convenient access to the underlying platform’s services C# is on very strong ground here, thanks to the NET Framework The NET Framework encompasses both the runtime and the libraries that C# programs use on Windows The runtime part is called the Common Language Runtime (usually abbreviated to CLR) because it supports not just C#, ... straightforward to use directly from C# Windows 8 introduces a new kind of API for writing full-screen applications optimized for tablet computers, an evolution of COM called WinRT, and—unlike interoperability with older native Windows APIs—using WinRT from C# feels very natural In summary, with C# we get a strong set of abstractions built into the language, a powIn summary, with C# we get a strong set of abstractions... and platform func tionality Why Not C#? To understand a language, it’s useful to compare it with alternatives, so it’s worth looking at some of the reasons you might choose some other language C# s nearest competitor is arguably Visual Basic (VB), another native NET language that offers most of the same benefits as C# The choice here is mostly a matter of syntax C# is part of the C family of languages,... it was no surprise that C# was one of the four languages to offer full support from the start for these applications (the others being C++, JavaScript, and Visual Basic) Although Microsoft invented C#, the language and its runtime are documented by the standards body ECMA, enabling anyone to implement C# This is not merely hypostandards body ECMA, enabling anyone to implement C# This is not merely hypo... for taking me on as an O’Reilly author back when I wrote my first book xx | Preface CHAPTER 1 Introducing C# The C# programming language (pronounced “see sharp”) can be used for many kinds of applications, including websites, desktop applications, games, phone apps, and command-line utilities C# has been center stage for Windows developers for about a decade now, so when Microsoft announced that Windows

Ngày đăng: 31/03/2014, 16:44

TỪ KHÓA LIÊN QUAN

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN