- ホーム
- > 洋書
- > 英文書
- > Computer / Languages
Full Description
Real Solutions for C# 4.0 ProgrammersNeed fast, robust, efficient code solutions for Microsoft C# 4.0? This book delivers exactly what you're looking for. You'll find more than 200 solutions, best-practice techniques, and tested code samples for everything from classes to exceptions, networking to XML, LINQ to Silverlight. Completely up-to-date, this book fully reflects major language enhancements introduced with the new C# 4.0 and .NET 4.0. When time is of the essence, turn here first: Get answers you can trust and code you can use, right now!Beginning with the language essentials and moving on to solving common problems using the .NET Framework, C# 4.0 How-To addresses a wide range of general programming problems and algorithms. Along the way is clear, concise coverage of a broad spectrum of C# techniques that will help developers of all levels become more proficient with C# and the most popular .NET tools.Fast, Reliable, and Easy to Use!Write more elegant, efficient, and reusable code Take advantage of real-world tips and best-practices advice Create more effective classes, interfaces, and types Master powerful data handling techniques using collections, serialization, databases, and XML Implement more effective user interfaces with both WPF and WinForms Construct Web-based and media-rich applications with ASP.NET and Silverlight Make the most of delegates, events, and anonymous methods Leverage advanced C# features ranging from reflection to asynchronous programming Harness the power of regular expressions Interact effectively with Windows and underlying hardware Master the best reusable patterns for designing complex programs
Contents
Introduction 1Overview of C# 4.0 How-To 1How-To Benefit from This Book 1How-To Continue Expanding Your Knowledge 3PART I: C# FUNDAMENTALSChapter 1 Type Fundamentals 7Create a Class 8Define Fields, Properties, and Methods 9Define Static Members 10Add a Constructor 11Initialize Properties at Construction 12Use const and readonly 13Reuse Code in Multiple Constructors 14Derive from a Class 14Call a Base Class Constructor 15Override a Base Class's Method or Property 16Create an Interface 19Implement Interfaces 19Create a Struct 21Create an Anonymous Type 22Prevent Instantiation with an Abstract Base Class 23Interface or Abstract Base Class? 24Chapter 2 Creating Versatile Types 27Format a Type with ToString() 28Make Types Equatable. 32Make Types Hashable with GetHashCode() 34Make Types Sortable 34Give Types an Index 36Notify Clients when Changes Happen 38Overload Appropriate Operators 39Convert One Type to Another 40Prevent Inheritance 41Allow Value Type to Be Null 42Chapter3 General Coding 45Declare Variables 46Defer Type Checking to Runtime (Dynamic Types) 47Use Dynamic Typing to Simplify COM Interop 49Declare Arrays 50Create Multidimensional Arrays 50Alias a Namespace 51Use the Conditional Operator (?:) 52Use the Null-Coalescing Operator (??) 53Add Methods to Existing Types with Extension Methods 54Call Methods with Default Parameters 55Call Methods with Named Parameters 56Defer Evaluation of a Value Until Referenced 57Enforce Code Contracts 58Chapter4 Exceptions 63Throw an Exception 64Catch an Exception 64Catch Multiple Exceptions 65Rethrow an Exception 66(Almost) Guarantee Execution with finally 67Get Useful Information from an Exception 68Create Your Own Exception Class 70Catch Unhandled Exceptions 72Usage Guidelines 76Chapter5 Numbers 77Decide Between Float, Double, and Decimal 78Use Enormous Integers (BigInteger) 79Use Complex Numbers 80Format Numbers in a String 82Convert a String to a Number 86Convert Between Number Bases 87Convert a Number to Bytes (and Vice Versa) 89Determine if an Integer Is Even 91Determine if an Integer Is a Power of 2 (aka, A Single Bit Is Set) 91Determine if a Number Is Prime 91Count the Number of 1 Bits 92Convert Degrees and Radians 93Round Numbers 93Generate Better Random Numbers 96Generate Unique IDs (GUIDs) 97Chapter6 Enumerations 99Declare an Enumeration 100Declare Flags as an Enumeration 101Determine if a Flag Is Set 102Convert an Enumeration to an Integer (and Vice Versa) 102Determine if an Enumeration Is Valid 103List Enumeration Values 103Convert a String to an Enumeration 103Attach Metadata to Enums with Extension Methods 104Enumeration Tips 106Chapter7 Strings 109Convert a String to Bytes (and Vice Versa) 110Create a Custom Encoding Scheme 111Compare Strings Correctly 115Change Case Correctly 116Detect Empty Strings 117Concatenate Strings: Should You Use StringBuilder? 117Concatenate Collection Items into a String 119Append a Newline Character 120Split a String 121Convert Binary Data to a String (Base-64 Encoding) 122Reverse Words 124Sort Number Strings Naturally 125Chapter8 Regular Expressions 131Search Text 132Extract Groups of Text 132Replace Text 133Match and Validate 134Help Regular Expressions Perform Better 137Chapter9 Generics 139Create a Generic List 140Create a Generic Method 141Create a Generic Interface 142Create a Generic Class 143Create a Generic Delegate 145Use Multiple Generic Types. 146Constrain the Generic Type 146Convert IEnumerable to IEnumerableConvert IComparer to IComparer (Contravariance) 150Create Tuples (Pairs and More) 151PART II: HANDLING DATAChapter 10 Collections 155Pick the Correct Collection Class 156Initialize a Collection 157Iterate over a Collection Independently of Its Implementation 158Create a Custom Collection 159Create Custom Iterators for a Collection 163Reverse an Array 166Reverse a Linked List 167Get the Unique Elements from a Collection 168Count the Number of Times an Item Appears 168Implement a Priority Queue 169Create a Trie (Prefix Tree) 173Chapter11 Files and Serialization 177Create, Read, and Write Files 178Delete a File 180Combine Streams (Compress a File) 181Get a File Size 183Get File Security Description 183Check for File and Directory Existence 185Enumerate Drives 185Enumerate Directories and Files 186Browse for Directories 187Search for a File or Directory 188Manipulate File Paths 190Create Unique or Temporary Filenames 192Watch for File System Changes 192Get the Paths to My Documents, My Pictures, Etc. 194Serialize Objects 194Serialize to an In-Memory Stream 198Store Data when Your App Has Restricted Permissions 198Chapter12 Networking and the Web 201Resolve a Hostname to an IP Address 202Get This Machine's Hostname and IP Address 202Ping a Machine 203Get Network Card Information 204Create a TCP/IP Client and Server 204Send an Email via SMTP 208Download Web Content via HTTP 209Upload a File with FTP 213Strip HTML of Tags 214Embed a Web Browser in Your Application 214Consume an RSS Feed 216Produce an RSS Feed Dynamically in IIS 220Communicate Between Processes on the Same Machine (WCF) 222Communicate Between Two Machines on the Same Network (WCF) 229Communicate over the Internet (WCF) 231Discover Services During Runtime (WCF) 233Chapter13 Databases 237Create a New Database from Visual Studio 238Connect and Retrieve Data 240Insert Data into a Database Table 245Delete Data from a Table 246Run a Stored Procedure 247Use Transactions 248Bind Data to a Control Using a DataSet 250Detect if Database Connection Is Available 258Automatically Map Data to Objects with the Entity Framework 259Chapter14 XML 261Serialize an Object to and from XML 262Write XML from Scratch 266Read an XML File 268Validate an XML Document 270Query XML Using XPath 271Transform Database Data to XML 273Transform XML to HTML 274PART III: USER INTERACTIONChapter 15 Delegates, Events, and Anonymous Methods 279Decide Which Method to Call at Runtime 280Subscribe to an Event 282Publish an Event 283Ensure UI Updates Occur on UI Thread 285Assign an Anonymous Method to a Delegate 288Use Anonymous Methods as Quick-and-Easy Event Handlers 288Take Advantage of Contravariance 291Chapter16 Windows Forms 295Create Modal and Modeless Forms 296Add a Menu Bar 297Disable Menu Items Dynamically 300Add a Status Bar 300Add a Toolbar 301Create a Split Window Interface 302Inherit a Form 304Create a User Control 308Use a Timer 313Use Application and User Configuration Values 314Use ListView Efficiently in Virtual Mode 317Take Advantage of Horizontal Wheel Tilt 319Cut and Paste 323Automatically Ensure You Reset the Wait Cursor 327Chapter17 Graphics with Windows Forms and GDI+ 329Understand Colors 330Use the System Color Picker 330Convert Colors Between RGB to HSV 331Draw Shapes 335Create Pens. 337Create Custom Brushes 339Use Transformations 341Draw Text 344Draw Text Diagonally 344Draw Images 344Draw Transparent Images 345Draw to an Off-Screen Buffer 346Access a Bitmap's Pixels Directly for Performance 347Draw with Anti-Aliasing 348Draw Flicker-Free 349Resize an Image 350Create a Thumbnail of an Image 351Take a Multiscreen Capture 352Get the Distance from the Mouse Cursor to a Point 354Determine if a Point Is Inside a Rectangle 355Determine if a Point Is Inside a Circle 355Determine if a Point Is Inside an Ellipse 356Determine if Two Rectangles Intersect. 357Print and Print Preview 358Chapter18 WPF 365Show a Window 366Choose a Layout Method 367Add a Menu Bar 367Add a Status Bar 369Add a Toolbar 369Use Standard Commands 370Use Custom Commands 371Enable and Disable Commands 374Expand and Collapse a Group of Controls 375Respond to Events 376Separate Look from Functionality 377Use Triggers to Change Styles at Runtime 378Bind Control Properties to Another Object 379Format Values During Data Binding 383Convert Values to a Different Type During Data Binding 383Bind to a Collection 385Specify How Bound Data Is Displayed 385Define the Look of Controls with Templates 386Animate Element Properties 388Render 3D Geometry 389Put Video on a 3D Surface 392Put Interactive Controls onto a 3D Surface 395Use WPF in a WinForms App 398Use WinForms in a WPF Application 400Chapter19 ASP.NET 401View Debug and Trace Information 402Determine Web Browser Capabilities 404Redirect to Another Page 405Use Forms Authentication for User Login 406Use Master Pages for a Consistent Look 409Add a Menu 411Bind Data to a GridView 412Create a User Control 414Create a Flexible UI with Web Parts 418Create a Simple AJAX Page 423Do Data Validation 425Maintain Application State 429Maintain UI State 430Maintain User Data in a Session 431Store Session State 433Use Cookies to Restore Session State 434Use ASP.NET Model-View-Controller (MVC) 436Chapter20 Silverlight 443Create a Silverlight Project 444Play a Video 445Build a Download and Playback Progress Bar 449Response to Timer Events on the UI Thread 451Put Content into a 3D Perspective 452Make Your Application Run out of the Browser 453Capture a Webcam 455Print a Document 457PART IV: ADVANCED C#Chapter 21 LINQ 461Query an Object Collection 462Order the Results 463Filter a Collection 464Get a Collection of a Portion of Objects (Projection) 465Perform a Join 465Query XML 466Create XML 467Query the Entity Framework 467Query a Web Service (LINQ to Bing) 469Speed Up Queries with PLINQ (Parallel LINQ) 472Chapter22 Memory Management 473Measure Memory Usage of Your Application 474Clean Up Unmanaged Resources Using Finalization 475Clean Up Managed Resources Using the Dispose Pattern 477Force a Garbage Collection 482Create a Cache That Still Allows Garbage Collection 482Use Pointers 485Speed Up Array Access 486Prevent Memory from Being Moved 487Allocate Unmanaged Memory 488Chapter23 Threads, Asynchronous, and Parallel Programming 491Easily Split Work Among Processors 492Use Data Structures in Multiple Threads 495Call a Method Asynchronously 496Use the Thread Pool 497Create a Thread 498Exchange Data with a Thread 499Protect Data Used in Multiple Threads 500Use Interlocked Methods Instead of Locks 503Protect Data in Multiple Processes 504Limit Applications to a Single Instance 505Limit the Number of Threads That Can Access a Resource 506Signal Threads with Events 509Use a Multithreaded Timer 512Use a Reader-Writer Lock 513Use the Asynchronous Programming Model 515Chapter24 Reflection and Creating Plugins 519Enumerate Types in an Assembly 520Add a Custom Attribute 521Instantiate a Class Dynamically 523Invoke a Method on a Dynamically Instantiated Class 523Implement a Plugin Architecture 525Chapter25 Application Patterns and Tips 529Use a Stopwatch to Profile Your Code 530Mark Obsolete Code 531Combine Multiple Events into a Single Event 532Implement an Observer (aka Subscriber) Pattern 536Use an Event Broker 540Remember the Screen Location 543Implement Undo Using Command Objects 545Use Model-View-ViewModel in WPF 552Understand Localization 562Localize a Windows Forms Application 563Localize an ASP.NET Application 564Localize a WPF Application 565Localize a Silverlight Application 570Deploy Applications Using ClickOnce 572Chapter26 Interacting with the OS and Hardware 575Get OS, Service Pack, and CLR Version 576Get CPU and Other Hardware Information 576Invoke UAC to Request Admin Privileges 578Write to the Event Log 581Access the Registry 583Manage Windows Services 584Create a Windows Service 585Call Native Windows Functions Using P/Invoke 588Call C Functions in a DLL from C# 589Use Memory-Mapped Files 590Ensure Your Application Works in Both 32-bit and 64-bit Environments 591Respond to System Configuration Changes 593Take Advantage of Windows 7 Features 593Retrieve Power State Information 595Chapter27 Fun Stuff and Loose Ends 597Create a Nonrectangular Window 598Create a Notification Icon 602Create a Screen Saver in WPF 605Show a Splash Screen 614Play a Sound File 619Shuffle Cards 620Appendix Essential Tools 621Reflector 622NUnit 623NDepend 626FXCop 626Virtual PC 627Process Explorer and Process Monitor 628RegexBuddy 630LINQPad 630Where to Find More Tools 631Index 633
-
- 洋書電子書籍
- ポーランドとウクライナにみる自由化の成…
-
- 洋書
-
カルヴァン
Calvin



