1. 首页
  2. 编程语言
  3. C#
  4. C# 5.0 in a Nutshell

C# 5.0 in a Nutshell

上传者: 2019-09-03 08:46:34上传 PDF文件 11.05MB 热度 105次
When you have a question about how to use C# 5.0 or the .NET CLR, this highly acclaimed bestseller has precisely the answers you need. Uniquely organized around concepts and use cases, this fifth edition include in-depth cover of concurrency and asynchrony new to C# 5.0 as well as continued coverageC#50INA NUTSHELLFifth editionJoseph albahari and ben albahari○ REILLY°Beijing· Cambridge· Farnham·Koln· Sebastopol· TokyoC#5.0 in a nutshell. fifth editionby Joseph albahari and Ben albahariCopyright@ 2012 Joseph Albahari and Ben Albahari. All rights reservedPrinted in the United States of americPublished by o'Reilly Media, Inc, 1005 Gravenstein Highway North, Sebastopol, CA 95472O'Reilly books may be purchased for educational, business, or sales promotional use. Onlineeditionsarealsoavailableformosttitles(http://my.safaribooksonline.com).Formoreinformation, contact our corporate/institutional sales department: 800-998-9938orcorporate oreilly. comEditor: Rachel roumeliotisIndexer: Jay MarchandProduction Editor: Melanie YarbroughCover designer Karen montgomeCopyeditor: Nancy ReinhardtInterior Designer: David FutatoProofreader: Jennifer KnightIllustrator: Robert romanoJune 2012Fifth editionRevision history for the fifth edition2012-06-08 First releaseSeehttp:/oreilly.com/catalog/errata.csp?isbn=9781449320102forreleasedetailsNutshell Handbook, the Nutshell Handbook logo, and the O'reilly logo are registered trademarks of O'Reilly Media, InC. C#5.0 in a Nutshell, the cover image of a numidian crane, andrelated trade dress are trademarks of o'Reilly media, IncMany of the designations used by manufacturers and sellers to distinguish their products areclaimed as trademarks. Where those designations appear in this book, and O'Reilly mediaInc, was aware of a trademark claim, the designations have been printed in caps or initial capsWhile every precaution has been taken in the preparation of this book, the publisher andauthors assume no responsibility for errors or omissions, or for damages resulting from theuse of the information contained hereinISBN:978-1-449-32010-21340210346Table of contentsPrefaceIntroducing C# and the NET FrameworkObject OrientationType safeMemory managemer2Platform SupportC#'s Relationship with the ClrThe clr and Net frameworkC# and windows runtimeWhat's New in C# 5.0What's New in C# 4.0What's New in C#3.02. C# Language basics....................... 9A First C# ProgramSyntax12Type b15Numeric types23Boolean Type and Operators30Strings and Charactersarrays34Variables and parameters38Expressions and operators47StatementsNamespacesⅢ3. Creating types in C#,,67Cl6Inheritance80The object Type8993Access modifiers94Interfaces96Enums102Nested types105enerics1064. Advanced c#119Delegates119Events128Lambda expressions135Anonymous Methodstry Statements and Exceptions140Enumeration and iterators148Nullable typesOperator Overloading158Extension methods162Anonymous Types164Dynamic binding165Attributes173Caller Info Attributes(C# 5175Unsafe Code and pointers177Preprocessor Directives180Ⅹ ML Documentation1825. Framework overview187The clr and core framework189Applied Technologies1946. Framework fundamentals,,,,,201String and Text Handling201Dates and Ti214Dates and Time Zones221Formatting and Parsing227Standard Format Strings and Parsing Flags233Other Conversion mechanisms240Globalization244Working with Numbers245Enums249Tuple252The Guid Struct253iv Table of ContentsEquality Comparison254Order Comparison264Utility Classes2677. Collections271Enumeration271The I Collection and IList Interfaces279The array class282Lists, Queues, Stacks, and sets291Dictionaries299Customizable collections and proxies306Plugging in Equality and Order3128. LINQ Queries,319Getting started319Fluent syntax321Query Expressions328Deferred execution332338Composition strategies342Projection Strategies345Interpreted Queries347LinQ to SQL and Entity Framework354Building Query Expiressions3689. LINQ Operators......375Overview377Filteringg379Projecting383Joining395Ordering403ping406Set operators409Conversion methods410Element operato413Aggregation Methods415Quantifiers419Generation Methods42010. LINQ to XML423Architectural overview423X-DOM Overview424Instantiateng an X-DOM427Navigating and Querying430Updating an X-DOm435Table of Contents IWorking with values438Documents and declarations441Names and namespaces444Annotations450Projecting into an X-DOM45011. other Xml technologies45Xmlreader458XmIwriter467Patterns for Using XmlReader/XmlWriter469Xmldocument473XPath477XSD and Schema validation481XSLT48412. Disposal and Garbage Collection485IDisposable, Dispose, and Close485Automatic Garbage Collection490Finalizers493How the garbage Collector Works497Managed Memory Leaks501Weak references50513. Diagnostics and Code Contracts509Conditional compilation509Debug and Trace Classe512Code Contracts Overview516Preconditions520Postconditions524Assertions and object Invariants527Contracts on interfaces and abstract methods528Dealing with Contract Failure529Selectively enforcing Contracts531Static Contract Checking533Debugger Integration535Processes and process threads536Stack Trace and stack Frame537Windows Event logs538Performance Counters541The Stopwatch Class54514. Concurrency asynchrony...................547Introduction547Threading548Tasks565vi Table of〔 ontentsPrinciples of asynchrony573Asynchronous Functions in C#5.0578Asynchronous Patterns594Obsolete p60115. Streams and v/o605Stream architecture605Using Streams607Stream Adapters621Compression streams629Working with Zip file631File and Directory Operations632File i/o in Windows runtime642Memory-Mapped Files644Isolated Storage64716. Networking…653Network architectureAddresses and PortsURIsClient-Side classes658Working with htTp671Writinganhttpserver677Using ftp680Using dns682Sending Mail with Smtp Client683Using TCP683Receiving POP3 Mail with TCP687TCP in Windows runtime68917. Serialization ., ............. 691Serialization Concepts691The data Contract serializer695Data Contracts and collections705Extending Data Contracts707The Binary serializer710Binary serialization attributes712Binary serialization with iserializable715Ⅹ ML Serialization71918. Assemblies∴,,,729What's in an assembly729Strong Names and Assembly Signing734assembly names737Authenticode signing739Table of contents|ⅶiThe global assembly Cache743Resources and satellite Assemblies745Resolving and Loading Assemblies754Deploying assemblies Outside the Base Folder759Packing a Single-File executable760Working with Unreferenced Assemblies76219. Reflection and metadata,,765Reflecting and Activating Types766Reflecting and Invoking membersReflecting assembl785Working with attributes786Dynamic Code Generation792Emitting Assemblies and TypesacEmitting Type Members803Emitting generic Methods and Types808Awkward Emission Targets810Parsing il81420. Dynamic Programming∴…821The Dynamic Language Runtime821Numeric Type unification823Dynamic Member Overload resolution824Implementing Dynamic Objects830Interoperating with Dynamic Languages83321.Security,837Permissions837Code access Security(Cas842Allowing Partially Trusted Callers845The transparency model847Sandboxing Another Assembly855Operating System Security858Identity and role security861crypto862Windows data Protection863Hashing864ymmetrIc Encryption865Public Key encryption and Signing87022. Advanced ThreadingSynchronization Overview876Exclusive Locking87Locking and Thread Safety884Non- Exclusive Locking89ⅶ ii Table of Contents
用户评论