Freeman | Introducing Visual C# 2010 | E-Book | www2.sack.de
E-Book

E-Book, Englisch, 1320 Seiten

Freeman Introducing Visual C# 2010


1. ed
ISBN: 978-1-4302-3172-1
Verlag: Apress
Format: PDF
Kopierschutz: 1 - PDF Watermark

E-Book, Englisch, 1320 Seiten

ISBN: 978-1-4302-3172-1
Verlag: Apress
Format: PDF
Kopierschutz: 1 - PDF Watermark



If you're new to C# programming, this book is the ideal way to get started. Respected author Adam Freeman guides you through the C# language by carefully building up your knowledge from fundamental concepts to advanced features. The book gradually builds up your knowledge, using the concepts you have already grasped to support those that come next. You will explore all the core areas of the C# language and the .NET Framework on which it runs. Particular attention is paid to the creation of Web and Windows applications and data access-danger zones where novice programmers often go awry in their early coding attempts. Introducing Visual C# 2010 is a comprehensive primer. Even if you have no previous programming experience, you can have confidence in the fact that you'll be able to build well constructed web and Windows applications of your own once you have finished reading this book.

Adam Freeman is an experienced IT professional who has held senior positions in a range of companies, most recently serving as chief technology officer and chief operating officer of a global bank. Now retired, he spends his time writing and long-distance running.

Freeman Introducing Visual C# 2010 jetzt bestellen!

Autoren/Hrsg.


Weitere Infos & Material


1;Title Page;1
2;Copyright Page;2
3;Contents at a Glance;4
4;Table of Contents;6
5;About the Authors;32
6;About the Technical Reviewers;33
7;Acknowledgments;34
8;PART 1 Getting Started;35
9;Chapter 1 Introduction;36
9.1;Who Should Read This Book?;36
9.2;What Is Covered in This Book?;36
9.3;What Do You Need to Read This Book?;37
9.4;What Is the Structure of This Book?;37
9.5;What Is in Each Chapter?;37
9.6;Getting the Example Code;39
9.7;Finding More Information;39
9.7.1;The MSDN C# Programming Guide;39
9.7.2;Online Forums;39
9.7.3;Other Books;39
9.8;Summary;39
10;Chapter 2 Getting Ready;40
10.1;Installing the Software;40
10.1.1;Installing Visual Studio 2010;40
10.1.2;Installing SQL Server 2008;42
10.1.3;Installing the Silverlight Tools;43
10.1.4;Downloading the Sample Code and Data;43
10.2;Creating Your First C# Project;43
10.2.1;Creating the Project;44
10.2.2;Editing the Code;46
10.2.3;Compiling and Running the Program;47
10.3;Features That I Use Before Explaining Them;47
10.3.1;The using statements;47
10.3.1.1;The namespace statement;48
10.3.1.2;The class statement;48
10.3.1.3;The Main method;48
10.3.1.4;The Code Comments;49
10.3.1.5;The Console.WriteLine and Console.ReadLine methods;49
10.4;Summary;49
11;Chapter 3 Understanding C# and the .NET Framework;50
11.1;C# and the .NET Framework at a Glance;50
11.1.1;Introducing C#;50
11.1.2;Introducing the .NET Framework;51
11.1.2.1;Introducing the Common Language Runtime;51
11.1.2.2;Introducing the Class Library;51
11.1.3;The Relationship between C# and the .NET Framework;52
11.1.3.1;Using C# Code Files;52
11.1.4;Understanding Assemblies;53
11.2;The Key Features of C# and the .NET Framework;55
11.2.1;Understanding Object-Orientation;55
11.2.2;Understanding Type Safety;55
11.2.3;Understanding Automatic Memory Management;56
11.2.4;Understanding the Just-In-Time Compiler;56
11.2.5;Understanding Parallel Processing;56
11.2.6;Understanding Unmanaged/Native Code Support;57
11.2.7;Understanding the .NET Technology Spectrum;57
11.2.7.1;Understanding ASP.NET;59
11.2.7.2;Understanding LINQ;59
11.2.7.3;Understanding the Task Parallel Library;60
11.2.7.4;Understanding User Interfaces;60
11.2.7.5;Understanding ADO.NET;61
11.2.7.6;Understanding the Windows Communication Foundation;62
11.3;Understanding .NET Cross-Platform Support;62
11.4;Summary;63
12;PART 2 The C# Language;64
13;Chapter 4 C# Fundamentals and Keyword Reference;66
13.1;Language Fundamentals;66
13.1.1;A Simple C# Program;66
13.1.2;C# Syntax;67
13.1.2.1;Identifiers;67
13.1.2.2;Keywords;70
13.1.2.3;Literals;70
13.1.2.4;Operators;71
13.1.2.5;Punctuators;72
13.1.2.6;Statements;73
13.1.2.7;Comments;73
13.1.3;Types;74
13.1.3.1;Value Types;75
13.1.3.2;Reference Types;76
13.1.3.3;Definite Assignment and Null References;78
13.2;Common Programming Tasks;79
13.2.1;Assigning Values;79
13.2.2;Making Comparisons;80
13.2.3;Performing Selections;82
13.2.3.1;Using an if Statement;82
13.2.3.2;Using a switch Statement;84
13.2.4;Iterating Data Items;86
13.2.4.1;Using a for Loop;86
13.2.4.2;Using a foreach Loop;89
13.2.4.3;Using a do...while Loop;91
13.2.4.4;Using a while Loop;92
13.3;Keyword and Operator Reference;93
13.3.1;Type Keywords;94
13.3.1.1;bool;95
13.3.1.2;byte, sbyte;95
13.3.1.3;char;95
13.3.1.4;class;96
13.3.1.5;decimal, double, float;96
13.3.1.6;delegate;97
13.3.1.7;dynamic;97
13.3.1.8;enum;98
13.3.1.9;interface;98
13.3.1.10;object;99
13.3.1.11;string;100
13.3.1.12;struct;100
13.3.1.13;short, ushort, int, uint, long, ulong;101
13.3.1.14;void;101
13.3.1.15;var;102
13.3.2;Modifiers;102
13.3.2.1;public, protected, private, internal;102
13.3.2.2;abstract;104
13.3.2.3;const;104
13.3.2.4;event;104
13.3.2.5;in, out;105
13.3.2.6;override;106
13.3.2.7;readonly;106
13.3.2.8;sealed;107
13.3.2.9;static;107
13.3.2.10;virtual;108
13.3.3;Selection Keywords;108
13.3.3.1;if, else;108
13.3.3.2;switch, case, default;108
13.3.4;Iterator Keywords;108
13.3.4.1;for;109
13.3.4.2;foreach;109
13.3.4.3;do, while;109
13.3.5;Jump Keywords;109
13.3.5.1;break;109
13.3.5.2;continue;109
13.3.5.3;goto;110
13.3.5.4;return;110
13.3.6;Exception Handling Keywords;110
13.3.6.1;throw;110
13.3.6.2;try, catch, finally;111
13.3.7;Arithmetic Overflow Keywords;111
13.3.7.1;checked, unchecked;111
13.3.8;Synchronization Keywords;112
13.3.8.1;lock;112
13.3.9;Parameter Keywords;112
13.3.9.1;params;112
13.3.9.2;ref;113
13.3.9.3;out;114
13.3.10;Namespace Keywords;114
13.3.10.1;namespace;114
13.3.10.2;using;115
13.3.11;Literal Keywords;115
13.3.11.1;null;115
13.3.11.2;true, false;116
13.3.12;Object Keywords;116
13.3.12.1;is, as;116
13.3.12.2;new;116
13.3.12.3;typeof;117
13.3.13;LINQ Keywords;117
13.3.14;Other Keywords;117
13.3.14.1;base;117
13.3.14.2;get, set, value;118
13.3.14.3;global;118
13.3.14.4;implicit, explicit;118
13.3.14.5;operator;119
13.3.14.6;partial;119
13.3.14.7;using;119
13.3.14.8;this;119
13.3.14.9;yield;119
13.3.15;Operators;120
13.3.15.1;[ ] Operator;120
13.3.15.2;( ) Operator;120
13.3.15.3;Dot (.) Operator;120
13.3.15.4;:: Operator;120
13.3.15.5;+, -, *, /, % Operators;121
13.3.15.6;==, !=, >, >=, <, <= Operators;121
13.3.15.7;++, +=, --, -= Operators;121
13.3.15.8;&&, || Operators;121
13.3.15.9;&, |, ^, ~, <<, >> Operators;121
13.3.15.10;=> Operator;122
13.3.15.11;=, +=, -=, *=, /=, %=, &=, >>=, <<=, ^= Operators;122
13.4;Summary;122
14;Chapter 5 Numeric and Boolean Types;123
14.1;Numeric Types;124
14.1.1;Using Numeric Literals;125
14.1.1.1;Using Literal Suffixes;127
14.1.1.2;Using Literal Prefixes;128
14.1.2;Implicit and Explicit Numeric Type Conversions;130
14.1.3;Using Overflow Checking;133
14.1.4;Using Struct Members;135
14.1.4.1;Common Members;135
14.1.4.2;Using Type-Specific Members;139
14.2;Using Numeric Operators;141
14.2.1;Arithmetic Operators;141
14.2.2;Unary Operators;145
14.2.3;Relational Operators;148
14.2.4;Logical Operators;150
14.2.5;Assignment Operators;154
14.3;Working with Very Large Integer Values;158
14.4;The Boolean Type;159
14.4.1;Using Boolean Literals;159
14.4.2;Using Boolean Results;160
14.4.3;Using Struct Members;161
14.5;Summary;162
15;Chapter 6 Classes and Objects;163
15.1;Creating a Basic Class;164
15.1.1;Adding Features to a Class;165
15.1.1.1;Adding Fields;165
15.1.1.2;Adding Methods;166
15.1.1.3;Adding a Constructor;167
15.1.2;Creating Objects from Classes;168
15.1.3;Using Objects;171
15.1.3.1;Reading and Modifying Fields;172
15.1.3.2;References to Common Objects;174
15.1.3.3;Using Static Fields;179
15.1.3.4;Calling Methods;180
15.2;Class Inheritance;182
15.2.1;Understanding Inheritance;185
15.2.1.1;Overriding Methods;188
15.2.1.2;Inheriting Derivations;189
15.2.2;Understanding Encapsulation;191
15.2.3;Understanding Polymorphism;192
15.3;Casting Objects and Type Checking;197
15.3.1;Implicit vs. Explicit Casting;197
15.3.1.1;Type Conversion Exceptions;201
15.3.1.2;Avoiding Explicit Cast Exceptions;202
15.3.1.2.1;Testing an Object’s Type;202
15.3.1.2.2;Casting Without Exceptions;204
15.3.1.3;Boxing and Unboxing;205
15.4;Using Nested Classes;207
15.5;Using Class Modifiers;208
15.5.1;Creating Static Classes;208
15.5.2;Creating Abstract Classes;210
15.5.3;Creating Sealed Classes;211
15.5.4;Creating Partial Classes;211
15.5.5;Using Access Modifiers;212
15.6;Summary;213
16;Chapter 7 Fields;214
16.1;Defining and Using Fields;215
16.1.1;Defining Fields;215
16.1.2;Initializing Fields;215
16.1.3;Reading and Updating Fields;217
16.1.3.1;Working Directly with Field Values;218
16.1.3.2;Allowing Other Classes to Read and Modify Properties;219
16.1.3.3;Exposing Properties with Field Values;220
16.1.3.4;Understanding Reference Type Fields;223
16.1.4;The Fourth Stage of the Life Cycle;224
16.2;Applying Field Modifiers;225
16.2.1;Creating Static Fields;225
16.2.2;Creating Read-Only Fields;227
16.2.2.1;Using the const keyword;227
16.2.2.2;Using the readonly Keyword;228
16.2.3;Applying Access Modifiers;230
16.2.4;Hiding Base Class Fields;230
16.2.5;Using the volatile Keyword;232
16.3;Summary;232
17;Chapter 8 Properties, Indexers, and Operators;233
17.1;Creating a Property;234
17.1.1;Creating a Field-Backed Property;234
17.1.2;Using a Property;237
17.1.3;Creating an Automatically Implemented Property;238
17.1.4;Creating an Asymmetric Property;239
17.1.5;Creating a Computed Property;239
17.1.6;Mapping a Property Type to a Field Type;240
17.1.7;Using Access Modifiers;240
17.1.8;Using Other Modifiers;241
17.1.8.1;Using the virtual and override Modifiers;242
17.1.8.2;Using the abstract Modifier;243
17.1.8.3;Using the sealed Keyword;243
17.1.8.4;Using the static Keyword;244
17.2;Creating an Indexer;245
17.2.1;Using Multiple Indexers;246
17.2.2;Creating a Validating Indexer;247
17.2.3;Creating an Indexer with Multiple Arguments;248
17.3;Creating Custom Operators;249
17.3.1;Creating Custom Unary Operators;249
17.3.2;Creating Custom Binary Operators;251
17.3.3;Creating Custom Conversion Operators;255
17.4;Summary;257
18;Chapter 9 Methods;258
18.1;Creating and Using a Simple Method;260
18.1.1;Defining the Method Name;261
18.1.2;Defining the Result Type;261
18.1.3;Defining the Parameters;262
18.1.4;Defining the Modifiers;263
18.1.5;Defining the Method Body;266
18.1.6;Using the Methods;267
18.2;Understanding Parameters;268
18.2.1;Using Value Parameters;268
18.2.2;Using Reference Parameters;272
18.2.3;Using Output Parameters;274
18.2.4;Using Parameter Arrays;276
18.2.5;Using Optional Parameters;278
18.2.6;Using Named Parameters;279
18.3;Understanding Method Bodies;280
18.3.1;Using Local Variables;280
18.3.1.1;Naming Variables;282
18.3.1.2;Understanding Variable Scope and Lifetime;284
18.3.2;Using Method Results;285
18.4;Understanding Method Modifiers;286
18.4.1;Using Access Modifiers;286
18.4.2;Creating Static Methods;286
18.4.3;Creating Virtual Methods;287
18.4.4;Creating Sealed Methods;287
18.4.5;Creating Abstract Methods;288
18.5;Overloading Methods;288
18.6;Hiding and Overriding Methods;291
18.6.1;Hiding Methods;292
18.6.2;Overriding Methods;294
18.6.3;Sealing Methods;296
18.6.4;Understanding Method Specialization;297
18.7;Special Methods;298
18.7.1;The Main Method;298
18.7.2;Constructors;301
18.7.2.1;Using the Default Constructor;303
18.7.2.2;Initializing Properties and Fields at Construction;303
18.7.2.3;Overloading Constructors;304
18.7.2.4;Calling Base Class Constructors;309
18.7.2.5;Controlling Access to Constructors;312
18.7.2.6;Creating Copy Constructors;313
18.7.2.7;Using Static Constructors;316
18.7.2.8;Creating Factory Methods;318
18.7.3;Destructors;319
18.7.4;Iterator Blocks;320
18.7.4.1;Using the yield Keyword;321
18.7.4.2;Exposing Field Iterators;322
18.7.4.3;Using Multiple yield Statements;323
18.7.4.4;Using Named Iterator Blocks;324
18.7.5;Partial Methods;325
18.7.6;Abstract Methods;328
18.7.7;Extension Methods;330
18.8;Summary;333
19;Chapter 10 Delegates, Events, and Anonymous Methods;334
19.1;Using Delegates;335
19.1.1;Using Delegates for Callbacks;337
19.1.2;Multicasting with Delegates;339
19.1.3;Delegating Selectively;341
19.1.4;Interrogating Delegates;342
19.2;Using Events;344
19.2.1;Defining and Publishing EventHandler Pattern Events;346
19.2.2;Creating Nongeneric Events;351
19.2.3;Creating Events Without Custom Data;352
19.2.4;Applying Modifiers to Events;354
19.3;Using Action and Func Delegates;355
19.3.1;Using Action Delegates;355
19.3.2;Using Func Delegates;357
19.4;Anonymous Methods;358
19.4.1;Capturing Outer Variables;360
19.5;Lambda Expressions;363
19.6;Summary;365
20;Chapter 11 Namespaces;366
20.1;Consuming Namespaces;366
20.1.1;Using Fully Qualified Names;367
20.1.2;Importing Namespaces;368
20.2;Creating Namespaces;369
20.2.1;Nesting Namespaces;371
20.2.2;Logically Nesting Namespaces;372
20.2.3;Spreading Namespaces Across Files;373
20.2.4;Adding Types to Existing Namespaces;375
20.3;Disambiguating Namespaces and Types;376
20.3.1;Disambiguation with Fully Qualified Names;378
20.3.2;Disambiguating with Aliases;378
20.3.3;Aliasing Namespaces;379
20.3.4;Resolving Type or Namespace Hiding;380
20.4;Summary;382
21;Chapter 12 Interfaces, Structs, and Enums;383
21.1;Using Interfaces;384
21.1.1;Defining and Using a Simple Interface;384
21.1.1.1;Defining an Interface;384
21.1.1.2;Implementing an Interface;385
21.1.1.3;Using an Interface;386
21.1.2;Specifying Interface Members;386
21.1.2.1;Specifying Methods;387
21.1.2.2;Specifying Properties;387
21.1.2.3;Specifying an Event;389
21.1.2.4;Specifying an Indexer;390
21.1.3;Deriving Interfaces;390
21.1.3.1;Deriving from Multiple Base Interfaces;391
21.1.4;Defining a Partial Interface;393
21.1.5;Implementing Interfaces;393
21.1.5.1;Implementing Multiple Interfaces;394
21.1.5.2;Explicitly Implementing an Interface;395
21.1.5.3;Inheriting Interface Implementations;397
21.1.5.4;Implementing an Interface in an Abstract Class;398
21.2;Using Structs;399
21.2.1;Defining and Instantiating a Struct;399
21.2.1.1;Implementing Interfaces;401
21.2.2;Differences Between Structs and Classes;402
21.2.2.1;Base Structs and Inheritance;403
21.2.2.2;Defining Fields;403
21.2.2.3;Defining a Struct Constructor;403
21.2.3;Copying a Struct;404
21.3;Using an Enum;408
21.3.1;Defining an Enum;408
21.3.2;Using an Enum;409
21.3.3;Using Underlying Types and Numeric Values;410
21.3.4;Combining Enum Values;411
21.4;Summary;412
22;Chapter 13 Arrays;413
22.1;Defining and Initializing Arrays;415
22.2;Getting and Setting Array Values;417
22.3;Using Array Initializers;419
22.4;Enumerating Arrays;421
22.4.1;Enumerating with a for Loop;421
22.4.2;Enumerating with a foreach Loop;423
22.4.3;Enumerating Using IEnumerator and IEnumerator;424
22.4.4;Breaking from Enumerations;426
22.5;Using System.Array Members;428
22.5.1;Sorting Arrays;428
22.5.2;Processing All of the Elements in an Array;429
22.5.3;Resizing and Copying an Array;430
22.5.4;Finding Items in an Array;434
22.6;Using Arrays with LINQ;436
22.7;Using Arrays as Collections;437
22.8;Using Multidimensional Arrays;437
22.8.1;Using Rectangular Arrays;438
22.8.1.1;Getting and Setting Rectangular Array Values;439
22.8.1.2;Using Rectangular Array Initializers;439
22.8.1.3;Enumerating a Rectangular Array;440
22.8.1.4;Creating Rectangular Arrays with Additional Dimensions;442
22.8.2;Using Jagged Arrays;443
22.8.2.1;Getting and Setting Jagged Array Values;444
22.8.2.2;Using Jagged Array Initializers;445
22.8.2.3;Enumerating a Jagged Array;445
22.9;Summary;446
23;Chapter 14 Exceptions;447
23.1;Handling Exceptions;448
23.1.1;Using try Statements and catch Clauses;449
23.1.2;Handling Different Exception Types;452
23.1.2.1;Using Specific catch Clauses;453
23.1.2.2;Using General catch Clauses;454
23.1.2.3;Omitting catch Clauses;454
23.1.3;Nesting try Statements;455
23.1.4;Using Exception Members;455
23.1.5;Using finally Clauses;458
23.2;Throwing Exceptions;460
23.2.1;Rethrowing Exceptions;464
23.2.2;Creating and Throwing Custom Exceptions;466
23.2.3;Throwing Meaningful Exceptions;469
23.2.3.1;Mapping One Exception Type to Another;470
23.2.3.2;Creating Exception Chains;472
23.2.3.3;Aggregating Exceptions;474
23.3;Summary;479
24;Chapter 15 Generic and Anonymous Types;480
24.1;Using Generic Types;481
24.1.1;Defining a Generic Class;483
24.1.2;Creating Objects from Generic Classes;483
24.1.3;Implementing and Using Generic Class Members;484
24.1.4;Defining Multiple Parameter Types;487
24.1.5;Casting from Parameterized Types;488
24.1.6;Constraining Parameterized Types;489
24.1.6.1;Applying Multiple Constrains to a Parameterized Type;491
24.1.6.2;Constraining Multiple Parameterized Types;492
24.1.7;Defining a Method-Specific Parameterized Type;492
24.1.8;Deriving from a Generic Base Class;494
24.1.8.1;Inheriting Type Deferral;494
24.1.8.2;Specifying Parameterized Types;497
24.1.9;Creating Generic Interfaces;498
24.1.10;Creating Generic Structs;499
24.1.11;Type Variance;499
24.1.11.1;Covariance;502
24.1.11.2;Contravariance;503
24.1.11.3;Combining Contravariance and Covariance;504
24.1.12;Using the default Keyword;504
24.2;Using Anonymous Types;505
24.3;Summary;507
25;Chapter 16 Strings and Characters;508
25.1;Working with Characters;509
25.1.1;Expressing Characters Using Literals;509
25.1.2;Performing Operations on Characters;510
25.1.3;Using Struct Members;511
25.2;Using Strings;513
25.2.1;Expressing Strings Using String Literals;513
25.2.1.1;Using String Escape Sequences and Verbatim Literals;514
25.2.2;Performing Operations on Strings;515
25.2.2.1;Comparing Strings;516
25.2.2.2;Combining Strings;518
25.2.2.3;Reading Individual Characters;519
25.2.2.4;Enumerating a String;520
25.2.2.5;Using Strings in a switch Statement;521
25.2.3;Using Regular Expressions;522
25.2.4;Using Class Members;523
25.2.4.1;Manipulating Strings;523
25.2.4.2;Searching Strings;526
25.2.4.3;Other Class Members;527
25.3;Using the StringBuilder Class;529
25.3.1;Creating a StringBuilder Object;529
25.3.2;Using a StringBuilder Object;529
25.3.2.1;Using the Append and Insert Methods;532
25.3.2.2;Using the StringBuilder Indexer;533
25.4;Formatting Strings;534
25.4.1;Using Composite Formatting;534
25.4.1.1;Other Composite Formatting Methods;535
25.4.1.2;Specifying Alignment;536
25.4.1.3;Escaping Braces;537
25.4.2;Formatting Types;538
25.4.2.1;Using a Format Component;538
25.4.3;Creating String Representations of Custom Types;541
25.4.4;Performing Custom Composite Formatting;543
25.5;Summary;545
26;Chapter 17 Attributes;546
26.1;Using Attributes;546
26.1.1;Applying Attributes with Parameters;548
26.2;Testing for an Attribute;549
26.2.1;Testing for an Attribute Applied to a Class;549
26.2.2;Testing for an Attribute Applied to a Field;552
26.2.3;Testing for an Attribute Applied to a Property;555
26.2.4;Testing for an Attribute Applied to a Method;557
26.3;Creating a Custom Attribute;559
26.3.1;Using a Custom Attribute;560
26.3.2;Defining Properties in a Custom Attribute;562
26.3.3;Controlling How a Custom Attribute Can Be Used;562
26.3.4;Controlling Attribute Inheritance;564
26.4;Summary;565
27;Chapter 18 Garbage Collection;566
27.1;Explicitly Running the Garbage Collector;567
27.2;Implementing a Destructor;568
27.2.1;Destructors vs. Finalizers;569
27.2.2;Problems with Destructors;570
27.2.2.1;Performance Impact;570
27.2.2.2;Uncertain Execution;570
27.2.2.3;Uncertain Ordering;570
27.3;Using Disposal;571
27.4;Using Weak References;573
27.5;Summary;574
28;PART 3 The .NET Class Library;575
29;Chapter 19 Collections;577
29.1;The ICollection Interface;579
29.2;Generic Lists;580
29.2.1;The IList Interface;581
29.2.2;The List Collection;582
29.2.2.1;Adding, Retrieving, and Removing Items;583
29.2.2.2;Finding List Items;585
29.2.2.3;Sorting List Items;591
29.2.2.4;Processing Items;597
29.2.2.5;Other List Members;598
29.2.3;The LinkedList Collection;601
29.2.3.1;Adding, Retrieving, and Removing Items;602
29.2.3.2;Finding List Items;606
29.2.4;The SortedList Collection;607
29.2.4.1;Adding, Retrieving, and Removing Items;608
29.2.4.2;Other SortedList Members;611
29.3;Generic Dictionaries;611
29.3.1;The IDictionary Interface;612
29.3.2;The KeyValuePair Structure;614
29.3.3;The Dictionary Collection;615
29.3.3.1;Adding, Retrieving, and Removing Items;616
29.3.3.2;Other Dictionary Members;618
29.3.4;The SortedDictionary Collection;619
29.4;Generic Sets;621
29.4.1;The ISet Interface;621
29.4.2;The HashSet Collection;623
29.4.3;The SortedSet Collection;625
29.5;Generic Queues and Stacks;628
29.5.1;The Queue Collection;628
29.5.2;The Stack Collection;630
29.6;Other Generic Collection Interfaces;632
29.6.1;The IComparer Interface;632
29.6.2;The IEqualityComparer Interface;634
29.7;Treating Arrays as Collections;635
29.8;Creating Constrained Collections;639
29.8.1;Read-Only Lists;639
29.8.2;Other Read-Only Collections;640
29.9;Legacy Collections;643
29.10;Summary;645
30;Chapter 20 Files, Streams, and IO;646
30.1;Working with Files and Directories;647
30.1.1;Using the System.IO.Directory Class;647
30.1.1.1;Enumerating Files and Directories;647
30.1.1.2;Getting and Setting Information for a File or Directory;653
30.1.1.3;Changing the Current Working Directory;654
30.1.2;Using the FileInfo and DirectoryInfo Classes;655
30.1.2.1;Using the FileInfo Class;656
30.1.2.2;Using the DirectoryInfo Class;659
30.1.3;Using the System.IO.File Class;664
30.1.3.1;Using the File Convenience Methods;665
30.1.3.2;Using the Stream, Reader, and Writer Methods;667
30.1.4;Using the System.IO.Path Class;668
30.1.5;Monitoring for Changes;670
30.1.5.1;Filtering the Monitored Files and Directories;673
30.1.5.2;Filtering the Triggers for a Change Event;674
30.2;Working with Streams, Readers, and Writers;675
30.2.1;Using Streams;675
30.2.1.1;Using the System.IO.Stream Class (in Detail);678
30.2.1.2;Using Base Streams;682
30.2.1.3;Using Pass-Through Streams;688
30.2.2;Using Readers and Writers;691
30.2.2.1;Reading and Writing Binary Data;692
30.2.2.2;Reading and Writing Textual Data;695
30.3;Summary;698
31;Chapter 21 Networking & WCF;699
31.1;Requesting Data;699
31.1.1;Using WebClient Members to Configure a Request;701
31.1.2;Using WebClient Members to Retrieve Data;703
31.1.2.1;Getting the WebClient Response Headers;704
31.1.3;Using WebClient Events;706
31.2;Programming with Sockets;708
31.2.1;Creating a Simple TCP Client & Server;708
31.2.1.1;Creating the Server;709
31.2.1.2;Creating the Client;713
31.2.2;Writing a Parallel Server;715
31.3;The Windows Communication Foundation;717
31.3.1;Creating the WCF Server;718
31.3.1.1;Creating the Service Contract;718
31.3.2;Creating the WCF Client;721
31.4;Other Useful Network Classes;724
31.4.1;Writing a Simple Web Server;724
31.4.2;Using Connectionless Networking;728
31.4.3;Using the Domain Name System;731
31.5;Summary;733
32;Chapter 22 Time & Dates;734
32.1;Measuring Small Amounts of Time;735
32.2;Working with Periods of Time;738
32.2.1;Creating and Using TimeSpan Values;738
32.2.2;Performing Operations on TimeSpan Values;742
32.2.3;Formatting TimeSpan Strings;743
32.2.3.1;Creating Custom TimeSpan Format Strings;744
32.3;Working with Particular Dates and Times;746
32.3.1;Creating and Using DateTime Values;747
32.3.2;Performing Operations on DateTime Values;750
32.3.3;Formatting DateTime Strings;753
32.3.3.1;Creating Custom DateTime Format Strings;754
32.4;Summary;756
33;Chapter 23 Serialization;757
33.1;Using Binary Serialization;758
33.1.1;Serializing Graphs of Objects;761
33.1.2;Serializing Multiple Objects to a Single Stream;763
33.1.3;Selectively Serializing Fields;766
33.1.4;Using Serialization Callbacks;767
33.1.5;Version Tolerance;770
33.1.5.1;Adding Tolerance for Specific Changes;773
33.2;Using SOAP Serialization;774
33.2.1;Version Tolerance;776
33.2.2;Serializing Generic Objects;777
33.3;Using XML Serialization;777
33.3.1;Selectively Serializing Fields;779
33.3.2;Mapping Members to Elements and Attributes;780
33.3.3;Changing the Name for Attributes and Elements;781
33.4;Using Data Contract Serialization;782
33.4.1;Preparing a Class for Data Contract Serialization;782
33.4.2;Generating Portable XML;783
33.4.3;Generating .NET-specific XML;784
33.4.4;Generating JSON;786
33.5;Summary;787
34;Chapter 24 Serialization;788
34.1;Understanding Single- and Multi-Threaded Execution;789
34.2;Getting Started with Tasks;793
34.2.1;Creating a Task;793
34.2.2;Starting a Task;794
34.2.3;Waiting for a Task;795
34.3;Getting Results from Tasks;797
34.4;Passing Parameters to a Task;799
34.5;Getting the Status of a Task;801
34.5.1;Using the Status Properties;803
34.6;Canceling Tasks;803
34.6.1;Checking and Throwing in a Single Statement;805
34.6.2;Cancelling Multiple Tasks;807
34.7;Handling Task Exceptions;808
34.7.1;Handling an Exception in a Task Body;808
34.7.2;Handling an Exception from a Trigger Method;810
34.7.2.1;Handling Exceptions from Multiple Tasks;811
34.7.3;Dealing with Exceptions using Task Properties;813
34.7.4;Using a Custom Exception Escalation Policy;815
34.8;Chaining Tasks Together;817
34.8.1;Creating a Simple Continuation;817
34.8.2;Getting Details of the Antecedent;818
34.8.3;Providing a Continuation Result;819
34.8.4;Creating Chains of Continuations;821
34.8.5;Creating Selective Continuations;822
34.9;Sharing Data between Tasks;824
34.9.1;Understanding a Critical Region;827
34.9.2;Creating a Critical Region;827
34.9.3;Avoiding Synchronization;829
34.10;Using Concurrent Collections;830
34.11;Summary;834
35;Chapter 25 Asynchronous Methods and Parallel Loops;835
35.1;Using Asynchronous Methods;836
35.1.1;Using Pre-Built Asynchronous Methods;836
35.1.2;Asynchronously Calling Any Method;839
35.1.3;Waiting for an Asynchronous Method to Complete;840
35.1.4;Mixing Asynchronous Methods and Tasks;843
35.2;Using Parallel Loops;844
35.2.1;Creating a Parallel ForEach Loop;844
35.2.2;Creating a Parallel For Loop;846
35.2.3;Breaking and Stopping Parallel Loops;847
35.3;Summary;851
36;Chapter 26 Other Useful Features and Classes;852
36.1;Converting Between Types;853
36.2;Returning Multiple Results from Methods Using Tuples;855
36.3;Aliasing Generic Types;858
36.4;Using Nullable Types;860
36.4.1;Using the Null-Coalescing Operator;861
36.5;Working with the Console;862
36.5.1;Reading from and Writing to the Console;862
36.5.2;Making the Console Beep;865
36.5.3;Modifying the Appearance of the Console;865
36.6;Generating Random Numbers;867
36.7;Converting Strings to and from Bytes;868
36.8;Getting Environment Information;869
36.9;Performing Math Operations;871
36.10;Using Conditional Compilation;872
36.10.1;Using Visual Studio to Define Symbols;874
36.10.2;Conditionally Compiling Methods;875
36.11;Checking Network Connectivity;877
36.11.1;Listening for Connectivity Changes;878
36.12;Summary;879
37;PART 4 Data and Databases;880
38;Chapter 27 LINQ to Objects;881
38.1;Performing a Simple LINQ Query;882
38.1.1;Understanding LINQ to Objects Data Sources;884
38.1.1.1;Enumerating Results Manually;885
38.1.1.2;Using Results as Data Sources;886
38.1.2;Understanding Query Results;888
38.1.2.1;The Range Variable Type;888
38.1.2.2;The Result Type;888
38.1.2.3;Explicitly Specifying the Range Variable Type;890
38.1.2.4;Letting the Compiler Infer Types;891
38.2;Performing LINQ Operations;892
38.2.1;Filtering Data;893
38.2.2;Projecting Data;894
38.2.2.1;Projecting a Single Member;895
38.2.2.2;Projecting Anonymous Types;896
38.2.2.3;Projecting Derived Data;897
38.2.3;Ordering Data;899
38.2.4;Grouping Data;903
38.2.5;Grouping Using a Boolean Value;905
38.2.6;Grouping Using an Anonymous Type;907
38.2.7;Querying Grouped Data;908
38.3;Using Method Syntax;909
38.4;Understanding Deferred Execution;913
38.4.1;Reusing Queries;913
38.4.2;Referring to Variables;914
38.4.3;Forcing Immediate Execution;915
38.5;Converting Query Results;917
38.6;Using Legacy Collections as LINQ Data Sources;920
38.6.1;Explicitly Specifying the Range Variable Type;920
38.6.2;Using Cast and OfType Extension Methods;921
38.7;Performing Advanced LINQ Operations;923
38.7.1;Aggregating Data;923
38.7.2;Joining Data;925
38.7.3;Creating Combinations of Data;928
38.7.4;Creating Additional Range Variables;929
38.8;Summary;931
39;Chapter 28 Parallel LINQ;932
39.1;Performing a Parallel LINQ Query;932
39.2;Understanding PLINQ Result Ordering;935
39.2.1;Preserving Order in a PLINQ query;937
39.3;Forcing Parallel Execution;938
39.4;Performing Queries without Results;939
39.5;Summary;940
40;Chapter 29 LINQ to XML;941
40.1;Using the LINQ XML Classes;942
40.1.1;Creating XML Declaratively;942
40.1.1.1;Using Arbitrary Types to Create XElements;944
40.1.1.2;Creating Other XML Node Types;946
40.1.1.3;Creating Valid XML Documents;948
40.1.2;Populating an XElement or XDocument with an IEnumerable;949
40.1.3;Reading and Writing XML Files;950
40.1.3.1;Saving XML;950
40.1.3.2;Loading XML;952
40.1.4;Processing XML Declaratively;952
40.1.4.1;Filtering Elements by Name;954
40.1.4.2;Finding All Descendants;955
40.1.5;Modifying XML;956
40.2;Using LINQ to XML Queries;960
40.2.1;Querying XML for Data;961
40.2.2;Creating XML from LINQ Queries;962
40.2.3;Create Objects from XML;965
40.2.4;Modifying and Transforming XML Data;966
40.2.4.1;Adding Elements to XML;966
40.2.4.2;Creating a CSV File from XML;968
40.2.4.3;Creating XML from CSV Data;969
40.2.4.4;Changing and Deleting Elements;971
40.2.5;Sorting XML;973
40.2.6;Grouping XML;974
40.2.7;Using Parallel LINQ to Process XML;976
40.3;Summary;979
41;Chapter 30 LINQ to Entities;980
41.1;Getting Ready;981
41.1.1;Preparing the Database;982
41.1.2;Creating the Model;982
41.2;Using LINQ to Entities;988
41.2.1;Using the Data Model Context;989
41.2.2;Using Table Properties and Row Objects;990
41.2.3;Understanding the IQueryable Interface;992
41.2.4;Enumerating the Results;993
41.3;Navigating Using Foreign Key Relationships;994
41.3.1;Querying Using Navigation Properties;997
41.3.2;Using Navigation Data Efficiently;998
41.4;Performing Common Database Operations;1000
41.4.1;Querying Data;1000
41.4.1.1;Compiling Queries;1000
41.4.1.2;Querying Views;1003
41.4.1.3;Querying Stored Procedures;1004
41.4.2;Inserting Data into the Database;1008
41.4.2.1;Inserting Attached Objects;1010
41.4.3;Updating Data in the Database;1011
41.4.4;Deleting Data;1013
41.5;Enabling Concurrency Checking;1014
41.6;Summary;1015
42;Chapter 31 LINQ to DataSet;1016
42.1;Connecting to and Querying a Database;1017
42.1.1;Setting Up the Database;1017
42.1.2;Creating a Connection to the Database;1019
42.1.2.1;Storing Connection Strings;1023
42.1.3;Executing a SQL Query;1025
42.2;Understanding the DataSet Class;1027
42.2.1;Enumerating Results with DataTable and DataRow Objects;1029
42.3;Querying DataSets with LINQ;1031
42.3.1;Perform Joins on a DataSet;1033
42.3.2;Comparing Data;1036
42.3.2.1;Querying for Data Intersects;1036
42.3.2.2;Subtracting Results;1038
42.4;Performing Database Operations Using Cached Data;1039
42.4.1;Inserting Data;1039
42.4.2;Modifying Data;1042
42.4.3;Deleting Data;1044
42.5;Summary;1045
43;PART 5 User Interfaces;1046
44;Chapter 32 Windows Forms;1048
44.1;Building a Stand-Alone Window Forms Program;1048
44.1.1;Creating the Project;1049
44.1.2;Adding the Controls;1051
44.1.3;Setting the Control Properties;1053
44.1.3.1;Configuring the Labels;1053
44.1.3.2;Configuring the TextBoxes and NumericUpDowns;1054
44.1.3.3;Configuring the Button;1056
44.1.4;Adding the MenuStrip and StatusStrip;1056
44.1.5;Setting the Control Names;1058
44.1.6;Setting the Tab Order;1060
44.1.7;Wiring the Controls;1060
44.1.7.1;Wiring the Quit Menu;1061
44.1.7.2;Wiring the TextBoxes;1063
44.1.7.3;Wiring the Button;1066
44.1.8;Setting the Icon;1068
44.1.9;Testing the Program;1068
44.2;Using Windows Forms Data Binding;1068
44.2.1;Creating the Project and Creating the Data Model;1068
44.2.2;Creating and Using the Object Data Source;1069
44.2.3;Formatting the Grid Control;1071
44.2.4;Loading the Data;1073
44.2.5;Wiring the Save Button;1073
44.2.6;Testing the Program;1074
44.2.7;Two Program Variations;1075
44.2.7.1;Filtering the Data with LINQ;1075
44.2.7.2;Displaying Data Fields;1076
44.3;Windows 7 UI Integration;1078
44.3.1;Using Aero Glass;1078
44.4;Summary;1081
45;Chapter 33 Windows Presentation Foundation;1083
45.1;Building a Stand-Alone WPF Program;1083
45.1.1;Creating the Project;1083
45.1.2;Adding the Controls;1086
45.1.3;Setting the Control Properties;1088
45.1.3.1;Configuring the Label Controls;1088
45.1.3.2;Configuring the TextBox Controls;1088
45.1.3.3;Configuring the TextBlock Control;1089
45.1.3.4;Configuring the Button;1090
45.1.3.5;Adding the StatusBar Item;1090
45.1.4;Adding the StatusBar Item;1091
45.1.5;Adding the Menu Item;1091
45.1.6;Setting the Tab Order;1091
45.1.7;Wiring the Controls;1092
45.1.7.1;Wiring the Quit Menu;1092
45.1.7.2;Wiring the TextBox Controls;1093
45.1.7.3;Wiring the Button;1094
45.1.8;Managing the Focus;1095
45.1.8.1;Focusing on the First Control;1095
45.1.8.2;Selecting the TextBox Text on Focus;1096
45.1.9;Setting the Program Icon and Window Name;1096
45.1.10;Testing the Program;1096
45.2;Using WPF Data Binding;1097
45.2.1;Formatting the DataGrid Control;1098
45.2.2;Loading the Data;1099
45.2.3;Wiring the Button;1099
45.2.4;Testing the Program;1100
45.3;Using WPF-Specific Features;1100
45.3.1;Using WPF Animations;1100
45.3.1.1;Creating the Project;1101
45.3.1.2;Adding the Animation;1101
45.3.1.3;Testing the Animation;1103
45.3.1.4;Combining Multiple Animations;1103
45.3.2;Using WPF Commands;1104
45.3.2.1;Creating the Project;1104
45.3.2.2;Configuring the Button Controls;1105
45.3.2.3;Adding and Configuring the MenuItem Control;1106
45.3.2.4;Binding the Command;1106
45.3.2.5;Selectively Activating the Command;1108
45.3.2.6;Using Commands to Set Control Content;1110
45.4;Summary;1138
46;Chapter 34 ASP.NET;1113
46.1;Building a Web Forms Program;1113
46.1.1;Creating the Project;1113
46.1.2;Adding the Controls;1116
46.1.3;Setting the Control Properties;1118
46.1.3.1;Configuring the Labels;1118
46.1.3.2;Configuring the TextBox Controls;1118
46.1.3.3;Configuring the Button;1120
46.1.4;Setting the Tab Order;1120
46.1.5;Wiring the Button Control;1121
46.1.6;Setting the Focus;1121
46.1.7;Testing the Program;1122
46.2;Using Web Forms Data Binding;1122
46.2.1;Create the Project and the Entity Data Model;1123
46.2.2;Adding the Web Form;1123
46.2.3;Creating the Web Forms Data Source;1123
46.2.4;Adding the GridView Control;1125
46.2.5;Testing the Program;1126
46.3;Using ASP.NET Dynamic Data;1127
46.3.1;Creating the Project;1127
46.3.2;Creating the Entity Data Model;1128
46.3.3;Registering the Data Model;1128
46.3.4;Testing the Program;1128
46.3.5;Customizing a Dynamic Data Application;1130
46.3.5.1;Changing the Name of a Table;1131
46.3.5.2;Changing the Name and Visibility of a Column;1133
46.3.5.3;Selecting Tables to Be Displayed;1134
46.3.5.4;Customizing the Display Template;1136
46.4;Summary;1138
47;Chapter 35 Silverlight;1139
47.1;Creating the Swimming Calculator;1140
47.1.1;Creating the Project;1140
47.1.2;Defining the Layout;1142
47.1.2.1;Adding Grid Columns;1142
47.1.2.2;Adding the StackPanel Controls;1144
47.1.3;Adding the TextBox Controls;1145
47.1.4;Adding the Label Controls;1146
47.1.5;Adding the TextBlock Control;1147
47.1.6;Adding the Button Control;1148
47.1.7;Adjusting the Layout;1149
47.1.8;Wiring the Button;1150
47.1.9;Adding a Child Window;1151
47.2;Using a WCF RIA Service;1154
47.2.1;Creating the Project;1155
47.2.2;Creating the Data Model;1155
47.2.3;Creating the Domain Service Class;1156
47.2.4;Creating the Silverlight Client;1158
47.2.4.1;Adding the Data;1159
47.2.4.2;Configuring the DataGrid Control;1159
47.2.4.3;Configuring the ComboBox Control;1160
47.2.4.4;Wiring the ComboBox Control;1161
47.2.5;Testing the Application;1163
47.3;Using Silverlight Out-of-Browser Support;1163
47.3.1;Configuring the Out-of-Browser Support;1164
47.4;Using a Silverlight Program Out-of-Browser;1166
47.4.1;Making Installation Part of the Interface;1167
47.4.2;Using Other Out-of-Browser Features;1171
47.5;Summary;1171
48;PART 6 Advanced Topics;1172
49;Chapter 36 Windows Integration;1173
49.1;Using the Windows Event Log;1173
49.1.1;Reading an Event Log;1174
49.1.2;Writing to an Event Log;1177
49.1.2.1;Creating the Event Source;1177
49.1.2.2;Writing Events;1178
49.2;Using Elevated Privileges;1179
49.3;Creating a Windows Service;1181
49.3.1;Creating the Service Class;1182
49.3.2;Adding the Service Functionality;1184
49.3.3;Adding the Service Installer;1186
49.3.4;Add the MSI Installer;1187
49.3.5;Installing the Service;1189
49.3.6;Creating the Client;1191
49.4;Using the Windows Registry;1191
49.4.1;Searching the Registry;1191
49.4.2;Reading and Modifying the Registry;1194
49.5;Summary;1195
50;Chapter 37 Cryptography and Security;1196
50.1;Encrypting and Decrypting Data;1197
50.1.1;Creating and Using Encryption Keys;1197
50.1.2;Encrypting Data;1200
50.1.3;Decrypting Data;1201
50.1.4;Using the Windows Data Protection API;1202
50.2;Using Hash Codes;1204
50.2.1;Generating a Hash Code;1205
50.2.2;Verifying a Hash Code;1207
50.3;Generating Secure Random Numbers;1208
50.4;Working Securely with Strings;1209
50.5;Summary;1211
51;Chapter 38 Testing and Debugging;1212
51.1;Using the Debug and Trace Classes;1213
51.1.1;Using the Debug Class;1213
51.1.1.1;Making Assertions;1215
51.1.1.2;Disabling Debug Statements;1217
51.1.1.3;Using Debug Listeners;1218
51.1.1.4;Other Debug Methods;1220
51.1.2;Using the Trace Class;1223
51.2;Using Static Code Analysis;1225
51.2.1;Selecting the Code Analysis Rules;1225
51.2.2;Performing Static Analysis;1226
51.2.3;Dealing with a Rule Violation;1227
51.2.3.1;Suppressing a Single Occurrence;1228
51.2.3.2;Suppressing Every Occurrence;1230
51.3;Using Code Contracts;1232
51.3.1;Installing and Enabling Code Contract Support;1232
51.3.2;Writing Code Contracts;1233
51.3.2.1;Using Precondition Contracts;1233
51.3.2.2;Using Postcondition Contracts;1234
51.3.2.3;Using Assertion Contracts;1235
51.3.2.4;Using Invariant Contracts;1236
51.3.3;Using the Static Checker;1237
51.3.4;Using the Runtime Checker;1240
51.4;Summary;1241
52;Index;1242



Ihre Fragen, Wünsche oder Anmerkungen
Vorname*
Nachname*
Ihre E-Mail-Adresse*
Kundennr.
Ihre Nachricht*
Lediglich mit * gekennzeichnete Felder sind Pflichtfelder.
Wenn Sie die im Kontaktformular eingegebenen Daten durch Klick auf den nachfolgenden Button übersenden, erklären Sie sich damit einverstanden, dass wir Ihr Angaben für die Beantwortung Ihrer Anfrage verwenden. Selbstverständlich werden Ihre Daten vertraulich behandelt und nicht an Dritte weitergegeben. Sie können der Verwendung Ihrer Daten jederzeit widersprechen. Das Datenhandling bei Sack Fachmedien erklären wir Ihnen in unserer Datenschutzerklärung.