Griffiths, I (2012) Programming C# 5.0: Building Windows 8, Web, and Desktop Applications for the .NET 4.5 Framework, O’Reilly Media; Inc.
Download eBook PDF (PDF 19,848KB)
Download Source Code (ZIP 1,191KB)
After a dozen years of incremental changes, C# has become one of the most versatile programming languages available. With this comprehensive guide, you’ll learn just how powerful the combination of C# 5.0 and .NET 4.5 can be. Author Ian Griffiths guides you through C# 5.0 fundamentals and teaches you techniques for building web and desktop applications, including Windows 8-style apps.
Completely rewritten for experienced programmers, this book provides many code examples to help you work with the nuts and bolts of C# code, such as generics, dynamic typing, and the new asynchronous programming features. You’ll also get up to speed on XAML, ASP.NET, LINQ, and other .NET tools.
- Discover how C# supports fundamental coding features such as classes, other custom types, collections, and error handling
- Understand the differences between dynamic and static typing in C#
- Query and process diverse data sources such as in-memory object models, databases, and XML documents with LINQ
- Use .NET’s multithreading features to exploit your computer’s parallel processing capabilities
- Learn how the new asynchronous language features can help improve application responsiveness and scalability
- Use XAML to create Windows 8-style, phone, and classic desktop applications
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#; 1.1 Why C#?; 1.2 Why Not C#?; 1.3 C#’s Defining Features; 1.4 Visual Studio; 1.5 Anatomy of a Simple Program; 1.6 Summary; Chapter 2: Basic Coding in C#; 2.1 Local Variables; 2.2 Statements and Expressions; 2.3 Comments and Whitespace; 2.4 Preprocessing Directives; 2.5 Intrinsic Data Types; 2.6 Operators; 2.7 Flow Control; 2.8 Summary; Chapter 3: Types; 3.1 Classes; 3.2 Structs; 3.3 Members; 3.4 Interfaces; 3.5 Enums; 3.6 Other Types; 3.7 Partial Types and Methods; 3.8 Summary; Chapter 4: Generics; 4.1 Generic Types; 4.2 Constraints; 4.3 Zero-Like Values; 4.4 Generic Methods; 4.5 Inside Generics; 4.6 Summary; Chapter 5: Collections; 5.1 Arrays; 5.2 List; 5.3 List and Sequence Interfaces; 5.4 Implementing Lists and Sequences; 5.5 Dictionaries; 5.6 Sets; 5.7 Queues and Stacks; 5.8 Linked Lists; 5.9 Concurrent Collections; 5.10 Tuples; 5.11 Summary; Chapter 6: Inheritance; 6.1 Inheritance and Conversions; 6.2 Interface Inheritance; 6.3 Generics; 6.4 System.Object; 6.5 Accessibility and Inheritance; 6.6 Virtual Methods; 6.7 Sealed Methods and Classes; 6.8 Accessing Base Members; 6.9 Inheritance and Construction; 6.10 Special Base Types; 6.11 Summary; Chapter 7: Object Lifetime; 7.1 Garbage Collection; 7.2 Destructors and Finalization; 7.3 IDisposable; 7.4 Boxing; 7.5 Summary; Chapter 8: Exceptions; 8.1 Exception Sources; 8.2 Handling Exceptions; 8.3 Throwing Exceptions; 8.4 Exception Types; 8.5 Unhandled Exceptions; 8.6 Asynchronous Exceptions; 8.7 Summary; Chapter 9: Delegates, Lambdas, and Events; 9.1 Delegate Types; 9.2 Inline Methods; 9.3 Events; 9.4 Delegates Versus Interfaces; 9.5 Summary; Chapter 10: LINQ; 10.1 Query Expressions; 10.2 Deferred Evaluation; 10.3 LINQ, Generics, and IQueryable; 10.4 Standard LINQ Operators; 10.5 Sequence Generation; 10.6 Other LINQ Implementations; 10.7 Summary; Chapter 11: Reactive Extensions; 11.1 Rx and .NET Versions; 11.2 Fundamental Interfaces; 11.3 Publishing and Subscribing with Delegates; 11.4 Sequence Builders; 11.5 LINQ Queries; 11.6 Rx Query Operators; 11.7 Schedulers; 11.8 Subjects; 11.9 Adaptation; 11.10 Timed Operations; 11.11 Summary; Chapter 12: Assemblies; 12.1 Visual Studio and Assemblies; 12.2 Anatomy of an Assembly; 12.3 Type Identity; 12.4 Loading Assemblies; 12.5 Assembly Names; 12.6 Portable Class Libraries; 12.7 Packaged Deployment; 12.8 Protection; 12.9 Summary; Chapter 13: Reflection; 13.1 Reflection Types; 13.2 Reflection Contexts; 13.3 Summary; Chapter 14: Dynamic Typing; 14.1 The dynamic Type; 14.2 dynamic and Interoperability; 14.3 Inside Dynamic; 14.4 Limitations of dynamic; 14.5 Summary; Chapter 15: Attributes; 15.1 Applying Attributes; 15.2 Defining and Consuming Custom Attributes; 15.3 Summary; Chapter 16: Files and Streams; 16.1 The Stream Class; 16.2 Windows 8 and IRandomAccessStream; 16.3 Text-Oriented Types; 16.4 Files and Directories; 16.5 Serialization; 16.6 Summary; Chapter 17: Multithreading; 17.1 Threads; 17.2 Synchronization; 17.3 Tasks; 17.4 Other Asynchronous Patterns; 17.5 Cancellation; 17.6 Parallelism; 17.7 Summary; Chapter 18: Asynchronous Language Features; 18.1 Asynchronous Keywords: async and await; 18.2 The await Pattern; 18.3 Error Handling; 18.4 Summary; Chapter 19: XAML; 19.1 XAML-Based Frameworks; 19.2 XAML Basics; 19.3 Layout; 19.4 Controls; 19.5 Text; 19.6 Data Binding; 19.7 Graphics; 19.8 Styles; 19.9 Summary; Chapter 20: ASP.NET; 20.1 Razor; 20.2 Web Forms; 20.3 MVC; 20.4 Routing; 20.5 Summary; Chapter 21: Interoperability; 21.1 Calling Native Code; 21.2 Platform Invoke; 21.3 COM; 21.4 Windows Runtime; 21.5 Unsafe Code; 21.6 C++/CLI and the Component Extensions; 21.7 Summary; Colophon;|
- Preface
- Chapter 1: Introducing C#
- Chapter 2: Basic Coding in C#
- Chapter 3: Types
- Chapter 4: Generics
- Chapter 5: Collections
- Chapter 6: Inheritance
- Chapter 7: Object Lifetime
- Chapter 8: Exceptions
- Chapter 9: Delegates, Lambdas, and Events
- Chapter 10: LINQ
- Chapter 11: Reactive Extensions
- Chapter 12: Assemblies
- Chapter 13: Reflection
- Chapter 14: Dynamic Typing
- Chapter 15: Attributes
- Chapter 16: Files and Streams
- Chapter 17: Multithreading
- Chapter 18: Asynchronous Language Features
- Chapter 19: XAML
- Chapter 20: ASP.NET
- Chapter 21: Interoperability
Purdum, J. (2013) Beginning Object-Oriented Programming with C# (Wrox Programmer to Programmer), John Wiley and Sons.
Download eBook PDF (PDF 19.066KB)
Download Source Code (ZIP 7,107KB)
Wrox beginners′ guides have the perfect formula for getting programming newcomers up and running. This one introduces beginners to object–oriented programming using C# to demonstrate all of the core constructs of this programming framework. Using real–world situations, you′ll discover how to create, test, and deliver your programs and how to work with classes, arrays, collections, and all the elements of object–oriented programming.
- Covers exactly what beginners, even those with no prior programming experience, need to know to understand object–oriented programming and start writing programs in C#
- Explains the advantages and disadvantages of C#, and tips for understanding C# syntax
- Explores properties, encapsulation, and classes; value data types; operands and operators; errors and debugging; variables; and reference types
- Shows how to use statement repetition and program loops, understand arrays and collections, and write your own classes
- Also covers inheritance and polymorphism
Beginning Object–Oriented Programming with C# uses the tried–and–true Wrox formula for making this popular programming method easy to learn.
Table of Contents
INTRODUCTION xxv
PART I: GETTING STARTED
CHAPTER 1: INTRODUCING C# 3
A Short History of Object–Oriented Programming (OOP) 4
Installing C# 5
Downloading Visual Studio Professional 5
A Test Program Using C# 8
Creating a Project 9
The C# Integrated Development Environment 10
The Major IDE Windows 10
Using the Source Code Window 12
Adding a Toolbox Object to a Windows Form 13
Changing the Text of a Label Object 14
Running the Program 16
Summary 16
CHAPTER 2: UNDERSTANDING OBJECTS 19
Understanding Objects 20
Everyday Use of Objects 20
Class Properties 20
Class Methods 22
How Many Properties, How Many Methods? 23
Classes Are Simplifi cations of Objects 23
What Do I Do After I’ve Defi ned a Class? 23
Instantiating an Object of a Class 26
I Have an Object…Now What? 29
Why Hide the Data Inside an Object? 32
Getting Started with Objects 32
Developing a Program Plan 38
Where to Start? The Five Program Steps 38
The Five Program Steps 38
Creating a Simple Application Using Objects 40
Using the Program Steps to Create a Program Plan 40
1: Initialization 40
2: Input 41
3: Process 42
4: Display 43
5: Termination 43
Using C# to Implement Your Program Plan 43
Critique of the btnDisplayOutput Click Event Code 53
Summary 54
PART II: UNDERSTANDING C# SYNTAX
CHAPTER 3: UNDERSTANDING DATA TYPES 59
Computer Data 59
Integer Data Types 60
Range of Integer Data Types 61
Understanding Binary Numbers 61
Signed Integer Values 62
Which Integer Should You Use? 62
Variable Naming Rules and Conventions 63
Floating–Point Data Types 71
Which Floating–Point Data Type Should You Use? 74
Monetary Values: The Decimal Data Type 74
Using IntelliSense to Locate Program Errors 76
Syntax Rules and Error Messages 76
The Boolean Data Type 77
Summary 79
CHAPTER 4: UNDERSTANDING C# STATEMENTS 81
Basic Building Blocks of a Programming Language 82
Operands and Operators 82
Expressions 83
Statements 83
Operator Precedence 84
Overriding the Default Precedence Order 85
Defi ning Variables 87
Defi ning a Variable from the Compiler’s Point of View 87
Step 1: Preliminary Syntax Checking 87
Step 2: Symbol Table Checking 87
Step 3: Defi ning a Variable 89
Using a Variable in a Program 90
Bucket Analogy 91
Types of Program Errors 93
Syntax Errors 93
Semantic Errors 93
Logic Errors 94
The Visual Studio Debugger 94
The Debugging Process 94
Making Repetitious Debugging Easier 95
Using the Visual Studio Debugger 97
Setting a Breakpoint 97
Using a Breakpoint to Examine Variables 98
Single–Stepping the Program 100
Defensive Coding 101
Write Your Code So That Someone Else Can Easily Understand It 101
Use Program Comments 101
Use Meaningful Variable Names 103
Avoid Magic Numbers 104
Use a Consistent Coding Style 105
Take a Break 105
Use a Second Set of Eyes 105
Summary 106
CHAPTER 5: UNDERSTANDING REFERENCE DATA TYPES 109
String Variables 110
Defi ning a String Reference Variable 110
The Meaning of null 111
Why Reference Types Are Diff erent from Value Types 113
Reference Variable Rules 113
Reference Type Variables Versus Value Type Variables 115
Why Do Reference Variables Work the Way They Do? 115
Pass by Value Versus Pass by Reference 116
A Little Effi ciency Gain 116
Using String Variables 117
String Concatenation 117
Shorthand Assignment Operators 117
String Manipulation 118
String Length 118
Letting IntelliSense Show You Properties and Methods 119
Using an IntelliSense Option 120
An Important Distinction Between Properties and Methods 120
Thinking About Object Properties and Methods 120
Strings and Escape Sequences 131
Verbatim String Literals 132
DateTime Reference Objects 133
DateTime and ToString( ) Conversions 133
Class Constructors 139
Invoking the Application 139
The UpdateTimeInfo( ) Method 140
Overloaded Methods 141
Method Signatures 142
The Refresh Button 143
Summary 144
CHAPTER 6: MAKING DECISIONS IN CODE 147
Relational Operators 148
Using Relational Operators―The if Statement 148
The if–else Statement 152
Shorthand for Simple if–else: The Ternary Operator 154
Style Considerations for if and if–else Statements 155
Nested if Statements 157
RDC 158
Logical Operators 160
Using the Logical Operators 162
Associativity 163
The switch Statement 164
Summary 167
CHAPTER 7: STATEMENT REPETITION USING LOOPS 169
Program Loops 170
Good Loops, Bad Loops 170
The Three Conditions of a Well–Behaved Loop 170
The for Loop 171
Increment and Decrement Operators 172
Sequencing in a for Loop 173
When to Use a for Loop 179
Nested for Loops 179
Use the Debugger as a Learning Tool 182
while Loops 182
Why Have More Than One Type of Loop? 184
do–while Program Loops 185
The continue Statement 189
Summary 190
CHAPTER 8: UNDERSTANDING ARRAYS AND COLLECTIONS 193
What Is an Array? 194
Some Array Details 195
Array Element Versus Array Index 195
N – 1 Rule 196
Casts 201
The ListView Object 201
Arrays Are Objects 206
Multidimensional Arrays 207
Initializing Arrays 211
Variations for Initializing an Array 212
Which Array Defi nition/Initialization Syntax Is Best? 212
Code Like a User 212
Initializing Multidimensional Arrays 213
Initializer Lists for String Objects 213
Ragged Arrays 215
Defi ning Ragged Arrays at Runtime 215
Collections 216
ArrayList Objects 218
Summary 221
PART III: WRITING YOUR OWN CLASSES
CHAPTER 9: DESIGNING CLASSES 227
Class Design 228
Scope 230
Block Scope 231
Local Scope 232
Class Scope 232
Namespace Scope 233
Visualizing Scope 233
Why Does C# Support Scope? 235
Think Before You Write 235
Designing a Program 236
The Five Program Steps 236
Initialization Step 236
Input Step 238
Process Step 238
Display Step 238
Termination Step 238
Look at the Forest, Not Just the Trees 238
UML Light 239
Access Specifi ers 239
Access Specifi ers and Scope 240
The static Keyword 241
UML Methods 242
Design Intent and Access Specifi ers for Methods 242
Class Property and Method Names 244
Think Like a User 245
The clsDates Design 245
namespace Modifi er 247
Class Organization 248
static Data Versus Instance Members 248
Property and Helper Methods 249
General Methods 249
User Interfaces Versus User Interfaces 252
Summary 252
CHAPTER 10: DESIGNING AND WRITING CUSTOM CLASSES 255
Constructors 256
Default Constructors 256
Nondefault Constructors 256
Constructor Overloading 257
Constructor Sloppiness 257
Fixing the Constructor Problem 258
Always Call the Default Constructor 259
Property Methods 259
Property Methods and Getters and Setters 260
Property Method Rules 261
How the get Property Methods Work 262
How Does Visual Studio Know Whether to
Use the get or set Statement Block? 263
What to Do if an Error Occurs in a Property Method 264
Method Coupling and Cohesion 266
Cohesion 266
Coupling 266
Class Design for Deck–of–Cards Program 267
UML Class Diagram for Shuffl e Deck Program 268
Class Constants and Properties 268
Class Methods 269
The clsCardDeck Code 273
Class Properties, Constructor, and Property Methods 275
Class General Methods 276
Designing a Card Game Using clsCardDeck 278
Design Considerations 279
What Kind of Architecture? 279
Sideways Refi nement 280
Summary 291
CHAPTER 11: EXCEPTION HANDLING AND DEBUGGING 295
Overview 296
Bugs 296
Syntax Errors 296
Semantic Errors 296
Logic Errors 297
Input Errors 297
Data Validation 297
Limit User Input 298
Check Boxes 301
Combination Boxes 302
Date and Time Input 304
Exception Handling 306
try–catch Statement Blocks 308
Anticipating a Specifi c Exception 310
Fuzzy Exception Messages 312
The fi nally Statement Block 313
Program Debugging 314
The Nature of the Beast 314
Detection 314
Isolation 316
The Visual Studio Debugger 316
The Locals Window 317
The Immediate Window 318
Single–Stepping Through the Program 318
Backing Up from a Breakpoint 319
The Debug Toolbar 319
Finding the Bug 320
Scaff old Code 321
Toggling Scaff old Code 322
Defensive Coding 322
Summary 323
CHAPTER 12: GENERICS 327
What Are Generics? 327
Recursion 333
Data Problems 333
Introduction to Generics 334
Generics Versus ArrayLists 334
Boxing and Unboxing 335
Generic Quicksort 343
Using Generics with Constraints and Interfaces 347
Interfaces 347
Why Use an Interface? 348
Using an Interface 349
How Do You Know an Interface Is Implemented for a Data Type? 350
Summary 354
PART IV: STORING DATA
CHAPTER 13: USING DISK DATA FILES 359
Directories 360
The DriveInfo Class 360
Directory Class 360
DirectoryInfo Class 361
File Class 367
FileInfo Class 368
Types of Files 369
Textual Versus Binary Data Files 370
Sequential Versus Random Access Files 380
Sequential Files 380
Advantages and Disadvantages of Sequential Files 380
Random Access Files 381
Fixed Record Sizes 381
Advantages and Disadvantages of Random Access Files 383
Serialization and Deserialization 411
To Serialize or Not to Serialize 417
MDI, Menus, and File Dialogs 418
Summary 422
CHAPTER 14: USING DATABASES 425
What Is a Database? 425
The Structure of a Database 426
Database Tables, Fields, and Records 426
Designing Fields for a Database Table 427
Data Normalization 428
Creating Your Own Databases 432
Using SQL Server Management Studio 432
Using SQL 435
The SELECT Statement 435
The WHERE Predicate 436
The ORDER BY Clause 436
Aggregates 437
A DBMS System 438
Displaying Database Data Without Data Binding 451
Performing the Query 452
Edit a Record (UPDATE) 454
Summary 456
CHAPTER 15: USING LINQ 459
Using LINQ 459
Query Keywords 460
Summary 470
PART V: ADVANCED TOPICS
CHAPTER 16: INHERITANCE AND POLYMORPHISM 475
What Is Inheritance? 476
An Inheritance Example 476
The Base and Derived Classes 478
The protected Access Specifi er 479
Advantages of Inherited Relationships 480
Base Classes Are Not Derived Classes 491
Abstract Classes 491
Polymorphism 492
Extension Methods 495
Summary 498
CHAPTER 17: PRINTING AND THREADING 501
Using a Printer 501
Threading 509
A Threading Program 510
What Have You Gained with Threading? 515
Refactoring 516
Rename 516
Extract Method 516
Summary 520
CHAPTER 18: WEB PROGRAMMING 523
Static Web Pages 523
Dynamic Web Pages 530
Summary 535
APPENDIX: ANSWERS TO EXERCISES 539
INDEX 577
Sharp, John (2013) Microsoft Visual C# 2013 Step by Step (Step by Step (Microsoft)), Microsoft Press
A more recent version of this book is available
Download eBook PDF (PDF 36,864KB)
Download Source Code (ZIP 91,459KB)
Your hands-on guide to Visual C# fundamentals
Expand your expertise—and teach yourself the fundamentals of Microsoft Visual C# 2013. If you have previous programming experience but are new to Visual C# 2013, this tutorial delivers the step-by-step guidance and coding exercises you need to master core topics and techniques.
Discover how to:
- Create and debug C# applications in Visual Studio 2013
- Work with variables, identifiers, statements, operators, and methods
- Create interfaces and define abstract classes
- Write robust code that can catch and handle exceptions
- Display and edit data using data binding with Microsoft ADO.NET Entity Framework
- Respond to user input and touchscreen gestures
- Handle events arising from multiple sources
- Develop your first Windows 8.1 apps
Table of Contents
Introduction; Who should read this book; Who should not read this book; Organization of this book; Conventions and features in this book; System requirements; Code samples; Acknowledgments; Errata and book support; We want to hear from you; Stay in touch; Introducing Microsoft Visual C# and Microsoft Visual Studio 2013; Chapter 1: Welcome to C#; 1.1 Beginning programming with the Visual Studio 2013 environment; 1.2 Writing your first program; 1.3 Using namespaces; 1.4 Creating a graphical application; 1.5 Summary; 1.6 Quick Reference; Chapter 2: Working with variables, operators, and expressions; 2.1 Understanding statements; 2.2 Using identifiers; 2.3 Using variables; 2.4 Working with primitive data types; 2.5 Using arithmetic operators; 2.6 Incrementing and decrementing variables; 2.7 Declaring implicitly typed local variables; 2.8 Summary; 2.9 Quick Reference; Chapter 3: Writing methods and applying scope; 3.1 Creating methods; 3.2 Applying scope; 3.3 Writing methods; 3.4 Using optional parameters and named arguments; 3.5 Summary; 3.6 Quick reference; Chapter 4: Using decision statements; 4.1 Declaring Boolean variables; 4.2 Using Boolean operators; 4.3 Using if statements to make decisions; 4.4 Using switch statements; 4.5 Summary; 4.6 Quick reference; Chapter 5: Using compound assignment and iteration statements; 5.1 Using compound assignment operators; 5.2 Writing while statements; 5.3 Writing for Statements; 5.4 Writing do statements; 5.5 Summary; 5.6 Quick reference; Chapter 6: Managing errors and exceptions; 6.1 Coping with errors; 6.2 Trying code and catching exceptions; 6.3 Using checked and unchecked integer arithmetic; 6.4 Throwing exceptions; 6.5 Using a finally block; 6.6 Summary; 6.7 Quick reference; Understanding the C# object model; Chapter 7: Creating and managing classes and objects; 7.1 Understanding classification; 7.2 The purpose of encapsulation; 7.3 Defining and using a class; 7.4 Controlling accessibility; 7.5 Understanding static methods and data; 7.6 Summary; 7.7 Quick reference; Chapter 8: Understanding values and references; 8.1 Copying value type variables and classes; 8.2 Understanding null values and nullable types; 8.3 Using ref and out parameters; 8.4 How computer memory is organized; 8.5 The System.Object class; 8.6 Boxing; 8.7 Unboxing; 8.8 Casting data safely; 8.9 Summary; 8.10 Quick reference; Chapter 9: Creating value types with enumerations and structures; 9.1 Working with enumerations; 9.2 Working with structures; 9.3 Summary; 9.4 Quick reference; Chapter 10: Using arrays; 10.1 Declaring and creating an array; 10.2 Populating and using an array; 10.3 Copying arrays; 10.4 Using multidimensional arrays; 10.5 Summary; 10.6 Quick reference; Chapter 11: Understanding parameter arrays; 11.1 Overloading—a recap; 11.2 Using array arguments; 11.3 Comparing parameter arrays and optional parameters; 11.4 Summary; 11.5 Quick reference; Chapter 12: Working with inheritance; 12.1 What is inheritance?; 12.2 Using inheritance; 12.3 Understanding extension methods; 12.4 Summary; 12.5 Quick reference; Chapter 13: Creating interfaces and defining abstract classes; 13.1 Understanding interfaces; 13.2 Abstract classes; 13.3 Sealed classes; 13.4 Summary; 13.5 Quick reference; Chapter 14: Using garbage collection and resource management; 14.1 The life and times of an object; 14.2 Resource management; 14.3 Implementing exception-safe disposal; 14.4 Summary; 14.5 Quick reference; Defining extensible types with C#; Chapter 15: Implementing properties to access fields; 15.1 Implementing encapsulation by using methods; 15.2 What are properties?; 15.3 Understanding the property restrictions; 15.4 Declaring interface properties; 15.5 Generating automatic properties; 15.6 Initializing objects by using properties; 15.7 Summary; 15.8 Quick reference; Chapter 16: Using indexers; 16.1 What is an indexer?; 16.2 Indexers in interfaces; 16.3 Using indexers in a Windows application; 16.4 Summary; 16.5 Quick reference; Chapter 17: Introducing generics; 17.1 The problem with the object type; 17.2 The generics solution; 17.3 Creating a generic class; 17.4 Creating a generic method; 17.5 Variance and generic interfaces; 17.6 Summary; 17.7 Quick reference; Chapter 18: Using collections; 18.1 What are collection classes?; 18.2 Using collection initializers; 18.3 The Find methods, predicates, and lambda expressions; 18.4 Comparing arrays and collections; 18.5 Summary; 18.6 Quick reference; Chapter 19: Enumerating collections; 19.1 Enumerating the elements in a collection; 19.2 Implementing an enumerator by using an iterator; 19.3 Summary; 19.4 Quick reference; Chapter 20: Decoupling application logic and handling events; 20.1 Understanding delegates; 20.2 Lambda expressions and delegates; 20.3 Enabling notifications by using events; 20.4 Understanding user interface events; 20.5 Summary; 20.6 Quick reference; Chapter 21: Querying in-memory data by using query expressions; 21.1 What is Language-Integrated Query?; 21.2 Using LINQ in a C# application; 21.3 Summary; 21.4 Quick reference; Chapter 22: Operator overloading; 22.1 Understanding operators; 22.2 Understanding compound assignment evaluation; 22.3 Declaring increment and decrement operators; 22.4 Comparing operators in structures and classes; 22.5 Defining operator pairs; 22.6 Implementing operators; 22.7 Understanding conversion operators; 22.8 Summary; 22.9 Quick reference; Building professional Windows 8.1 applications with C#; Chapter 23: Improving throughput by using tasks; 23.1 Why perform multitasking by using parallel processing?; 23.2 Implementing multitasking by using the Microsoft .NET Framework; 23.3 Canceling tasks and handling exceptions; 23.4 Summary; 23.5 Quick reference; Chapter 24: Improving response time by performing asynchronous operations; 24.1 Implementing asynchronous methods; 24.2 Using PLINQ to parallelize declarative data access; 24.3 Synchronizing concurrent access to data; 24.4 Summary; 24.5 Quick reference; Chapter 25: Implementing the user interface for a Windows Store app; 25.1 What is a Windows Store app?; 25.2 Using the Blank App template to build a Windows Store app; 25.3 Summary; 25.4 Quick reference; Chapter 26: Displaying and searching for data in a Windows Store app; 26.1 Implementing the Model-View-ViewModel pattern; 26.2 Summary; 26.3 Quick reference; Chapter 27: Accessing a remote database from a Windows Store app; 27.1 ; 27.2 Summary; 27.3 Quick reference; About the author;|
- Introduction
- Introducing Microsoft Visual C# and Microsoft Visual Studio 2013
- Chapter 1: Welcome to C#
- Chapter 2: Working with variables, operators, and expressions
- Chapter 3: Writing methods and applying scope
- Chapter 4: Using decision statements
- Chapter 5: Using compound assignment and iteration statements
- Chapter 6: Managing errors and exceptions
- Understanding the C# object model
- Chapter 7: Creating and managing classes and objects
- Chapter 8: Understanding values and references
- Chapter 9: Creating value types with enumerations and structures
- Chapter 10: Using arrays
- Chapter 11: Understanding parameter arrays
- Chapter 12: Working with inheritance
- Chapter 13: Creating interfaces and defining abstract classes
- Chapter 14: Using garbage collection and resource management
- Defining extensible types with C#
- Chapter 15: Implementing properties to access fields
- Chapter 16: Using indexers
- Chapter 17: Introducing generics
- Chapter 18: Using collections
- Chapter 19: Enumerating collections
- Chapter 20: Decoupling application logic and handling events
- Chapter 21: Querying in-memory data by using query expressions
- Chapter 22: Operator overloading
- Building professional Windows 8.1 applications with C#
- Chapter 23: Improving throughput by using tasks
- Chapter 24: Improving response time by performing asynchronous operations
- Chapter 25: Implementing the user interface for a Windows Store app
- Chapter 26: Displaying and searching for data in a Windows Store app
- Chapter 27: Accessing a remote database from a Windows Store app
Watson, K., Hammer, J. V., Reid, J. D. , Skinner, M. Kemper, D. and Nagel, C (2013) Beginning Visual C# 2012 Programming, Wrox, John Wiley and Sons
Download eBook PDF (PDF 18,024KB)
Download Source Code: http://eu.wiley.com/WileyCDA/WileyTitle/productCd-1118314417.html
Step–by–step beginner’s guide to Visual C# 2012 Written for novice programmers who want to learn programming with C# and the .NET framework, this book offers programming basics such as variables, flow control, and object oriented programming. It then moves into web and Windows programming and data access (databases and XML). The authors focus on the tool that beginners use most often to program C#, the Visual C# 2012 development environment in Visual Studio 2012. Puts the spotlight on key beginning level topics with easy–to–follow instructions for Microsoft Visual C# 2012 Explores how to program for variables, expressions, flow control, and functions Explains the debugging process and error handling as well as object oriented programming, and much more Beginning Microsoft Visual C# 2012 Programming offers beginners a guide to writing effective programming code following simple step–by–step methods, each followed by the opportunity to try out newly acquired skills.
Step-by-step beginner’s guide to Visual C# 2012Written for novice programmers who want to learn programming with C# and the .NET framework, this book offers programming basics such as variables, flow control, and object oriented programming. It then moves into web and Windows programming and data access (databases and XML). The authors focus on the tool that beginners use most often to program C#, the Visual C# 2012 development environment in Visual Studio 2012.
- Puts the spotlight on key beginning level topics with easy-to-follow instructions for Microsoft Visual C# 2012
- Explores how to program for variables, expressions, flow control, and functions
- Explains the debugging process and error handling as well as object oriented programming, and much more
Beginning Microsoft Visual C# 2012 Programming offers beginners a guide to writing effective programming code following simple step-by-step methods, each followed by the opportunity to try out newly acquired skills.
Table of Contents
INTRODUCTION xxxi
PART I: THE C# LANGUAGE
CHAPTER 1: INTRODUCING C# 3
CHAPTER 2: WRITING A C# PROGRAM 13
CHAPTER 3: VARIABLES AND EXPRESSIONS 25
CHAPTER 4: FLOW CONTROL 49
CHAPTER 5: MORE ABOUT VARIABLES 79
CHAPTER 6: FUNCTIONS 105
CHAPTER 7: DEBUGGING AND ERROR HANDLING 131
CHAPTER 8: INTRODUCTION TO OBJECT–ORIENTED PROGRAMMING 157
CHAPTER 9: DEFINING CLASSES 177
CHAPTER 10: DEFINING CLASS MEMBERS 203
CHAPTER 11: COLLECTIONS, COMPARISONS, AND CONVERSIONS 235
CHAPTER 12: GENERICS 279
CHAPTER 13: ADDITIONAL OOP TECHNIQUES 313
CHAPTER 14: C# LANGUAGE ENHANCEMENTS 339
PART II: WINDOWS PROGRAMMING
CHAPTER 15: BASIC DESKTOP PROGRAMMING 381
CHAPTER 16: ADVANCED DESKTOP PROGRAMMING 425
CHAPTER 17: WINDOWS STORE APPS 469
CHAPTER 18: DEPLOYING DESKTOP APPLICATIONS 513
PART III: WEB PROGRAMMING
CHAPTER 19: ASP.NET WEB PROGRAMMING 535
CHAPTER 20: DEPLOYING WEB APPLICATIONS 591
PART IV: DATA ACCESS
CHAPTER 21: FILE SYSTEM DATA 605
CHAPTER 22: XML 639
CHAPTER 23: INTRODUCTION TO LINQ 663
CHAPTER 24: APPLYING LINQ 699
PART V: ADDITIONAL TECHNIQUES
CHAPTER 25: WINDOWS COMMUNICATION FOUNDATION 727
APPENDIX A: EXERCISE SOLUTIONS 779
INDEX 827
Allwork, J. (2010) Visual Studio C# Programming and PC Interfacing, Elektor International Media
This book aims to teach you quickly how to program a PC, using the popular C# high level programming language. The tuition begins with data types and program flow and extends to more advanced concepts such as object oriented programming, threading, internet communications and databases. All code examples used are available free of charge from the www.elektor.com support website; you can easily create your own results to demonstrate the concepts explained and reinforce your learning in the process.
Professional quality software tools are downloadable also free of charge from Microsoft. The Microsoft Visual Studio 2010 environment is extensively covered with user controls and their properties, methods and events.
Detailed guidance is provided for those wishing to control hardware from a PC with PC interfacing chapters which explain the legacy serial and parallel ports, analogue interfacing using the sound card and use of Microsoft DirectX drivers. Interfacing to the ubiquitous USB port is explained in-depth with a detailed hardware and software design for a USB connected PIC-based hardware target included.
This book is complete with the many full program examples, self assessment exercises and links to supporting videos.
Support is also provided for University lecturers in the form of accompanying downloadable PowerPoint presentations for most chapters.
This latest book by Dr John Allwork supports C# development using the latest Microsoft Visual Studio 2010 and Microsoft Windows 7 operating system.
Clark, D. (2013) Beginning C# Object-Oriented Programming – Learn to Design and Develop Modern Applications in C# (Expert’s Voice in .NET), Second Edition, Apress
Download eBook PDF (PDF 6,060KB)
Download Source Code (ZIP 474KB)
- Learn C# with Beginning C# Object-Oriented Programming and you’ll be thinking about program design in the right way from day one.
Whether you want to work with .NET for the web or desktop, or for Windows 8 on any device, Dan Clark’s accessible, quick-paced guide will give you the foundation you need for a successful future in C# programming.
In this book you will: - Master the fundamentals of object-oriented programming
- Work through a case study to see how C# and OOP work in a real-world application
- Develop techniques and best practices that lead to efficient, reusable, elegant code
- Discover how to transform a simple model of an application into a fully-functional C# project.
With more than 30 fully hands-on activities, Beginning C# Object-Oriented Programming teaches you how to design a user interface, implement your business logic, and integrate your application with a relational database for data storage. Along the way, you will explore the .NET Framework, ASP.NET and WinRT. In addition, you will develop desktop, mobile and web-based user interfaces, and service-oriented programming skills, all using Microsoft’s industry-leading Visual Studio 2012, C#, the Entity Framework, and more. Read this book and let Dan Clark guide you in your journey to becoming a confident C# programmer. What you’ll learn - Lay the foundations of great C# programming by understanding object-oriented programming (OOP) principles.
- Understand how OOP can be applied across desktop, web and mobile worlds in Windows today.
- Learn to use the Universal Modeling Language (UML) to quickly design an application correctly from the first attempt.
- Discover the .NET Framework, ASP.NET and WinRT and how they can help you create applications quickly and efficiently. Walk along as the author guides you through a final challenge, to develop a complete application using a wide range of the techniques and best practices covered inside.
Learn C# with Beginning C# Object-Oriented Programming and you’ll be thinking about program design in the right way from day one. Whether you want to work with .NET for the web or desktop, or for Windows 8 on any device, Dan Clark’s accessible, quick-paced guide will give you the foundation you need for a successful future in C# programming. In this book you will: Master the fundamentals of object-oriented programming Work through a case study to see how C# and OOP work in a real-world application Develop techniques and best practices that lead to efficient, reusable, elegant code Discover how to transform a simple model of an application into a fully-functional C# project. With more than 30 fully hands-on activities, Beginning C# Object-Oriented Programming teaches you how to design a user interface, implement your business logic, and integrate your application with a relational database for data storage. Along the way, you will explore the .NET Framework, ASP.NET and WinRT. In addition, you will develop desktop, mobile and web-based user interfaces, and service-oriented programming skills, all using Microsoft’s industry-leading Visual Studio 2012, C#, the Entity Framework, and more. Read this book and let Dan Clark guide you in your journey to becoming a confident C# programmer. What you’ll learn Lay the foundations of great C# programming by understanding object-oriented programming (OOP) principles. Understand how OOP can be applied across desktop, web and mobile worlds in Windows today. Learn to use the Universal Modeling Language (UML) to quickly design an application correctly from the first attempt. Discover the .NET Framework, ASP.NET and WinRT and how they can help you create applications quickly and efficiently. Walk along as the author guides you through a final challenge, to develop a complete application using a wide range of the techniques and best practices covered inside. Who this book is for If
Learn C# with Beginning C# Object-Oriented Programming and you’ll be thinking about program design in the right way from day one. Whether you want to work with .NET for the web or desktop, or for Windows 8 on any device, Dan Clark’s accessible, quick-paced guide will give you the foundation you need for a successful future in C# programming.
In this book you will:
- Master the fundamentals of object-oriented programming
- Work through a case study to see how C# and OOP work in a real-world application
- Develop techniques and best practices that lead to efficient, reusable, elegant code
- Discover how to transform a simple model of an application into a fully-functional C# project.
With more than 30 fully hands-on activities, Beginning C# Object-Oriented Programming teaches you how to design a user interface, implement your business logic, and integrate your application with a relational database for data storage. Along the way, you will explore the .NET Framework, ASP.NET and WinRT. In addition, you will develop desktop, mobile and web-based user interfaces, and service-oriented programming skills, all using Microsoft’s industry-leading Visual Studio 2012, C#, the Entity Framework, and more. Read this book and let Dan Clark guide you in your journey to becoming a confident C# programmer.
What you’ll learn
- Lay the foundations of great C# programming by understanding object-oriented programming (OOP) principles.
- Understand how OOP can be applied across desktop, web and mobile worlds in Windows today.
- Learn to use the Universal Modeling Language (UML) to quickly design an application correctly from the first attempt.
- Discover the .NET Framework, ASP.NET and WinRT and how they can help you create applications quickly and efficiently.
- Walk along as the author guides you through a final challenge, to develop a complete application using a wide range of the techniques and best practices covered inside.
Bishop. J. and Horspool, N. (2004) C# Concisely, Addison-Wesley, Pearson Education Ltd
Download Source Files (ZIP 372KB)
Companion Web Site: http://cscsharp.cs.uvic.ca/index.html
C# (‘C Sharp’) is an object-oriented, network-enabled programming language, developed expressly for Microsoft’s .Net platform. C# provides the features that are the most important to programmers: object-orientation, graphics, GUI components, internet-based client/server networking and distributed computing C# Concisely is an introductory text which teaches object-oriented programming using the C# language. The reader is involved in object-orientation from the beginning, while developing skills in the use of control structures and data structures. The book covers nearly all of the language and its important namespaces, including collections and networking, and works through polymorphism and extensibility thoroughly.
While targeted at first year students, C# Concisely is equally applicable for those wishing to convert from other languages, and will be an invaluable resource for students at all levels.
Table of Contents
Preface
1: Introduction
2: Using objects
3: Inside objects
4: Control and arrays
5: Graphical user interfaces with Views
6: Exceptions and Debugging
7: Files and streams
8: Collections
9: Polymorphism and inheritance
10: Graphics and networking
The appendixes are:
A: List of Forms
B: Keywords and operators
C: Formatters
D: Unicode
E: Useful namespaces
F: The Views.Form class
G: Debugging with Windows
Description
C# (‘C Sharp’) is an object-oriented, network-enabled programming language, developed expressly for Microsoft’s .Net platform. C# provides the features that are the most important to programmers: object-orientation, graphics, GUI components, internet-based client/server networking and distributed computing. C# Concisely is an introductory text which teaches object-oriented programming using the C# language. The reader is involved in object-orientation from the beginning, while developing skills in the use of control structures and data structures. The book covers nearly all of the language and its important namespaces, including collections and networking, and works through polymorphism and extensibility thoroughly. While targeted at first year students, C# Concisely is equally applicable for those wishing to convert from other languages, and will be an invaluable resource for students at all levels.
Features
- Strong focus on complete programs as examples throughout the book including six case studies
- Use of object-oriented concepts from the beginning
- Extensive use of GUIs in programming examples to give them a modern and visually interesting feel
- A chapter and an appendix devoted to debugging C# programs using tools provided on the Windows platform
- Quiz questions and programming exercises are provided at the end of every chapter. Summaries of key language features appear throughout, and the book contains several appendices for reference
- Concludes with a chapter giving the student a taste of graphics, events, networking and web programming.
Table of Contents
Preface
1: Introduction
2: Using objects
3: Inside objects
4: Control and arrays
5: Graphical user interfaces with Views
6: Exceptions and Debugging
7: Files and streams
8: Collections
9: Polymorphism and inheritance
10: Graphics and networking
The appendixes are:
A: List of Forms
B: Keywords and operators
C: Formatters
D: Unicode
E: Useful namespaces
F: The Views.Form class
G: Debugging with Windows
Back Cover
C# is an object-oriented, network-enabled programming language,
developed expressly for Microsoft’s .NET platform. C# and the
associated class libraries provide the features that are the most
important to programmers: object-orientation, graphics,
GUI components, internet-based client-server networking and
distributed computing.
C# Concisely
is an introductory text which teaches object-oriented
programming using the C# language. The reader is involved in
object-orientation from the beginning, while developing skills in the
use of control structures and data structures. The book covers nearly
all of the language and its important namespaces, including collections
and networking, and works through polymorphism and extensibility
in depth.
Key Features
- Strong focus on complete programs as examples throughout the book
- Use of object-oriented concepts from the beginning
- Extensive use of GUIs to give programs a modern and visually
interesting feel
- A chapter and an appendix devoted to debugging C# programs
- Quiz questions and programming exercises are provided at the end of
every chapter.
- Summaries of key language features appear throughout, in a novel and
precise way
- Several appendices cross-reference key features in the book
- Includes a chapter giving a taste of graphics, events, networking and web
programming.
While targeted at first year students, C# Concisely is equally
applicable for those wishing to convert from other languages, and will
be an invaluable resource for students at all levels.
Anderson, T. (2004) C# in Easy Steps – Learn to Program with Visual C#, Computer Step
Download Source Code (ZIP 647KB)
Learn to program with Microsoft’s premier programming language. No previous programming knowledge is assumed. With numerous easy-to-follow examples, this title explains the essentials of object-oriented programming with C# and how to build both Windows and web applications using the designers and tools in Visual Studio or the standalone Visual C# product.
This title puts the emphasis on learning by doing, and even novices will have simple programs running after just a few pages. The early chapters explain how to build form-based applications with an explanation of key Windows controls such as buttons, listboxes, tabs and dialogs. Next comes an explanation of the C# language, covering statements, operators, variables and data types, and how to interpret all those semi-colons and curly brackets. There’s a complete chapter on the essentials of object orientation. With the fundamentals in place, the reader is taken through creating menus, simple database programming, web-based applications using ASP.Net, and tips for writing robust and high-performance code.
About the author
Tim Anderson is a well known author and journalist who specialises in software development. He writes regularly for magazines including Personal Computer World, PC Pro and Application Development Advisor. He also runs a small company engaged in developing custom applications.
Contents
- Getting Started
- Controls Explained
- C# Language Essentials
- Object Essentials
- Visual Studio Tools
- C# Techniques
- Creating Database Programs
- Running C# on the Internet
Bell, D. and Parr, M. (2009) C# For Students, Revised Edition, Addison Wesley, Pearson Education Limited
Download Source Code (ZIP 2,045KB)
Companion Web Site: http://www.mikeparr.info/csharp1st/csabout.html
If you are new to computer programming then this book is for you! Starting from scratch, it assumes no prior knowledge of programming and is written in a simple, direct style for maximum clarity.
C# (‘C Sharp’) is an object-oriented, network-enabled programming language, developed expressly for Microsoft’s .Net platform. C# provides the features that are the most important to programmers: object-orientation, graphics, GUI components, multimedia, internet-based client/server networking and distributed computing. ‘C# for Students’ explains key programming concepts and the central ideas of object oriented programming, using C# as the vehicle language.
· Programming for graphics is used from the start, and graphics are used repeatedly throughout the text to illustrate ideas. This approach engages the interest of the reader and improves their understanding.
· Objects introduced later. Delaying the coverage of objects until basic control structures and methods have been covered gives a firm foundation to the understanding of programming
· Complete programs are used rather than fragments to aid understanding
· Examples (an information system, computer game and a mathematical problem) are used to illustrate key programming concepts throughout the text
· Self test questions will appear on every page, as well as exercises, programming principles and programming pitfalls. The book is accompanied by a full online supplements package
|
|
C# is a complete Object-Oriented language with encapsulation, inheritance and polymorphism. It is likely to be the main programming language for new Microsoft software systems.
Detailed contents
Preface
1.The background to C#
2.The C# development environment
3.Introductory graphics
4.Variables and calculations
5.Methods and arguments
6.Using objects
7.Selection
8.Repetition
9.Debugging
10. Writing classes
11. Inheritance
12. Calculations
13. Data structures – list boxes and array lists
14. Arrays
15. Arrays – two-dimensional
16. String manipulation
17. Exceptions
18. Files
19. Console programs
20. Object-oriented design
21. Program style
22. Testing
23. Interfaces
24. Polymorphism
Appendices
Bibliography
Index
Fagerberg, J. (2013) C# Programming: The ultimate way to learn the fundamentals of the C# language, CreateSpace Independent Publishing Platform
Download Source Code (ZIP 29,974KB)
Companion Web Site (with Source Code): http://sourcecodeacademy.azurewebsites.net/
Let me help you become a top C# developer in no time by removing hurdles and save you countless hours of searching the web
The book C# Programming is one of the best investments you can make in yourself, it will give you a-ha moments and take your programming skills to the next level.
It does not matter if you are just starting out with C#, or if you have been programming for a couple of years, this book, videos and source code will surely help you immensely. The book is easy to read and understand, with many complete code samples.
Your Path To Success
Here’s what two developers wrote to me about the book: “C# Tutorials” is a tightly written but yet comprehensive book that covers everything you need to know to master the C# language. The book has plenty of code examples and is littered with references to additional reading for real in-depth knowledge. I highly recommend this book for anyone aspiring to pass the MCSD Exam 70-483. – Peter Röök, independent software consultant I particularly like that there there is no fluff to fill out the book, that is so common in these types of books. The examples are short, clean and “to the point”. The illustrations are nice, the code is very well written, the book is airy and has nice formatting. The book covers a lot, I read it to advance my competence in C#/VS 2012/.NET. This is a very nice book, well done! – Thomas Engelin, independent software consultant It does not matter if you are just starting out with Visual C# or if you have been working as a solution developer for a while, this book has much to offer you. The book is easy to read and understand, with a lot of complete code samples. The first chapters of the book describe the fundamentals of the C# language such as variables, loops and methods. The book then gets progressively more challenging, describing, among other things, WCF Services, asynchronous operations, synchronizing concurrent data, reflection, the CodeDOM, and encrypting data. If you are aspiring to take the Microsoft exam 70-483 this book is an asset you do not want to miss out on. Apart from great code samples, it also contains a lot of suggested reading to make certain that you stand the best chance to complete the exam successfully. The author has worked professionally with Visual C# since it was released, and has taught C# and Visual Basic.NET as a Microsoft Certified Instructor for a number of years during his career.
I particularly like that there there is no fluff to fill out the book, that is so common in these types of books. The examples are short, clean and “to the point”. The illustrations are nice, the code is very well written, the book is airy and has nice formatting. The book covers a lot, I read it to advance my competence in C#/VS 2012/.NET. This is a very nice book, well done! – Thomas Engelin, independent software consultant
It does not matter if you are just starting out with Visual C# or if you have been working as a solution developer for a while, this book has much to offer you. The book is easy to read and understand, with a lot of complete code samples.
The first chapters of the book describe the fundamentals of the C# language such as variables, loops and methods. The book then gets progressively more challenging, describing, among other things, WCF Services, asynchronous operations, synchronizing concurrent data, reflection, the CodeDOM, and encrypting data.
If you are aspiring to take the Microsoft exam 70-483 this book is an asset you do not want to miss out on. Apart from great code samples, it also contains a lot of suggested reading to make certain that you stand the best chance to complete the exam successfully.
The author has worked professionally with Visual C# since it was released, and has taught C# and Visual Basic.NET as a Microsoft Certified Instructor for a number of years during his career.
De Smet, B. (2013) C# 5.0 Unleashed, Sams Publishing, Pearson Education, Inc
A more recent version of this book is available C# 6.0 Unleashed
Download eBook PDF (PDF 47,166KB)
Download Source Code (ZIP 239KB)
C# 5.0 Unleashed is for anyone who wants to learn the C# programming language in depth, understanding how language features truly work. While giving you those insights, you learn where and how to use the features to design various kinds of software. This book not only teaches the language’s capabilities, it also looks behind the scenes to build a solid foundation to aid you in understanding the .NET platform as a whole.
¿
Bart De Smet offers exceptional insight into the features of both the language and Microsoft’s broader framework. He doesn’t just cover the “what” and “how” of effective C# programming: He explains the “why,” so you can consistently choose the right language and platform features, maximizing your efficiency and effectiveness.
¿
The early chapters introduce the .NET platform, the tooling ecosystem, and the C# programming language, followed by in-depth coverage of the C# programming language itself, with immediate application of language features. The last chapters give an overview of the .NET Framework libraries about which every good developer on the platform should know.
-
Understand the .NET platform: its language support, libraries, tools, and more
-
Learn where C# fits, how it has evolved, and where it’s headed
-
Master essential language features including expressions, operators, types, objects, and methods
-
Efficiently manage exceptions and resources
-
Write more effective C# object-oriented code
-
Make the most of generics, collections, delegates, reflection, and other advanced language features
-
Use LINQ to express queries for any form of data
-
Master dynamic programming techniques built on .NET’s Dynamic Language Runtime (DLR)
-
Work with namespaces, assemblies, and application domains
-
Write more efficient code using threading, synchronization, and advanced parallel programming techniques
-
Leverage the Base Class Library (BCL) to quickly perform many common tasks
-
Instrument, diagnose, test, and troubleshoot your C# code
-
Understand how to use the new C# 5.0 asynchronous programming features
-
Leverage interoperability with Windows Runtime to build Windows 8 applications
Buy the print C# 5.0 Unleashed and get the eBook version for free! See inside the book for access code and details.
C# 5.0 Unleashed is for anyone who wants to learn the C# programming language in depth, understanding how language features truly work. While giving you those insights, you learn where and how to use the features to design various kinds of software. This book not only teaches the language’s capabilities, it also looks behind the scenes to build a solid foundation to aid you in understanding the .NET platform as a whole.
Bart De Smet offers exceptional insight into the features of both the language and Microsoft’s broader framework. He doesn’t just cover the “what” and “how” of effective C# programming: He explains the “why,” so you can consistently choose the right language and platform features, maximizing your efficiency and effectiveness.
The early chapters introduce the .NET platform, the tooling ecosystem, and the C# programming language, followed by in-depth coverage of the C# programming language itself, with immediate application of language features. The last chapters give an overview of the .NET Framework libraries about which every good developer on the platform should know.
- Understand the .NET platform: its language support, libraries, tools, and more
- Learn where C# fits, how it has evolved, and where it’s headed
- Master essential language features including expressions, operators, types, objects, and methods
- Efficiently manage exceptions and resources
- Write more effective C# object-oriented code
- Make the most of generics, collections, delegates, reflection, and other advanced language features
- Use LINQ to express queries for any form of data
- Master dynamic programming techniques built on .NET’s Dynamic Language Runtime (DLR)
- Work with namespaces, assemblies, and application domains
- Write more efficient code using threading, synchronization, and advanced parallel programming techniques
- Leverage the Base Class Library (BCL) to quickly perform many common tasks
- Instrument, diagnose, test, and troubleshoot your C# code
- Understand how to use the new C# 5.0 asynchronous programming features
- Leverage interoperability with Windows Runtime to build Windows 8 applications
Table of Contents
Introduction 1
Who Should Read This Book? 2
What You Need to Know Before You Read This Book 2
How This Book Is Organized 3
1 Introducing the NET Platform 5
A Historical Perspective 5
A 10,000-Feet View of the NET Platform. 9
The Common Language Infrastructure 12
The Multilanguage Aspect of NET 15
Introducing NET Assemblies. 16
The Common Type System Explained 17
Executing Managed Code 24
Diving into the Common Language Runtime 32
The Base Class Library 51
Summary 54
2 Introducing the C# Programming Language 55
The Evolution of C# 55
A Sneak Peek at the Future 95
Summary 102
3 Getting Started with NET Development Using C# 103
Installing the NET Framework 103
Your First Application: Take One 113
Visual Studio 2012 119
Your First Application: Take Two 127
Summary 173
4 Language Essentials 175
The Entry Point 175
Keywords 181
A Primer on Types 184
Built-In Types 190
Local Variables. 212
Intermezzo on Comments 223
Arrays 230
The Null Reference 239
Nullable Value Types 243
Summary 249
5 Expressions and Operators 251
What Are Expressions? 251
The Evaluation Stack 255
Arithmetic Operators 258
String Concatenation 269
Shift Operators 274
Relational Operators 275
Logical Operators 277
Conditional Operators 281
An Operator’s Result Type 284
Null-Coalescing Operator 285
Assignment 287
Summary 299
6 A Primer on Types and Objects 301
Implicit Versus Explicit Conversions 301
The typeof Operator: A Sneak Peek at Reflection 319
Default Value Expression 322
Creating Objects with the new Operator 324
Member Access 336
Invocation Expressions 340
Element Access 348
Summary 349
7 Simple Control Flow 351
What Are Statements, Anyway? 351
Expression Statements 353
The Empty Statement 355
Statement Blocks. 356
Declarations 357
Selection Statements 358
Iteration Statements 375
A Peek at Iterators 391
Loops in the Age of Concurrency 398
The goto Statement 400
The return Statement 404
Summary 406
8 Basics of Exceptions and Resource Management 407
Exception Handling 407
Deterministic Resource Cleanup 438
Locking on Objects 448
Summary 462
9 Introducing Types 463
Types Revisited 463
Classes Versus Structs 466
Type Members 486
Summary 499
10 Methods 501
Defining Methods 501
Specifying the Return Type 502
Declaring Parameters 504
Overloading 519
Extension Methods 524
Partial Methods 534
Extern Methods 538
Refactoring 540
Code Analysis 545
Summary 546
11 Fields, Properties, and Indexers 547
Fields 547
An Intermezzo About Enums 563
Properties 574
Indexers 580
Summary 583
12 Constructors and Finalizers 585
Constructors 585
Static Constructors 592
Destructors (Poorly Named Finalizers) 595
Summary 608
13 Operator Overloading and Conversions 609
Operators 609
Conversions 633
Summary 647
14 Object-Oriented Programming 649
The Cornerstones of Object Orientation 649
Inheritance for Classes 663
Protected Accessibility 674
Polymorphism and Virtual Members 676
Abstract Classes 688
Interface Types 690
Summary 699
15 Generic Types and Methods 701
Life Without Generics 701
Getting Started with Generics 704
Declaring Generic Types 707
Using Generic Types 712
Performance Intermezzo 714
Operations on Type Parameters 718
Generic Constraints 720
Generic Methods 736
Co- and Contravariance 743
Summary 754
16 Collection Types 755
Nongeneric Collection Types 755
Generic Collection Types 765
Thread-Safe Collection Types 778
Other Collection Types 786
Summary 787
17 Delegates 789
Functional Programming 789
What Are Delegates? 794
Delegate Types 794
Delegate Instances 798
Invoking Delegates 811
Putting It Together: An Extensible Calculator 815
Case Study: Delegates Used in LINQ to Objects 819
Asynchronous Invocation 823
Combining Delegates 835
Summary 842
18 Events 843
The Two Sides of Delegates 844
A Reactive Application 845
How Events Work 853
Raising Events, the Correct Way 855
add and remove Accessors 857
Detach Your Event Handlers 861
Recommended Event Patterns 871
Case Study: INotifyProperty Interfaces and UI Programming 880
Countdown, the GUI Way 890
Event Interoperability with WinRT 896
Introduction to Reactive Programming 898
Summary 911
19 Language Integrated Query Essentials 913
Life Without LINQ 914
LINQ by Example 921
Query Expression Syntax 931
Summary 975
20 Language Integrated Query Internals 977
How LINQ to Objects Works 977
Standard Query Operators 1000
The Query Pattern 1033
Parallel LINQ 1036
Expression Trees 1045
Summary 1055
21 Reflection 1057
Typing Revisited, Static and Otherwise. 1058
Reflection 1063
Lightweight Code Generation 1091
Expression Trees 1101
Summary 1117
22 Dynamic Programming 1119
The dynamic Keyword in C# 4.0 1119
DLR Internals 1137
Office and COM Interop 1159
Summary 1174
23 Exceptions 1175
Life Without Exceptions 1175
Introducing Exceptions 1178
Exception Handling 1180
Throwing Exceptions 1196
Defining Your Own Exception Types 1198
(In)famous Exception Types 1201
Summary 1220
24 Namespaces 1221
Organizing Types in Namespaces 1221
Declaring Namespaces 1227
Importing Namespaces 1231
Summary 1240
25 Assemblies and Application Domains 1241
Assemblies 1241
Application Domains 1286
Summary 1298
26 Base Class Library Essentials 1301
The BCL: What, Where, and How? 1303
The Holy System Root Namespace 1311
Facilities to Work with Text 1356
Summary 1372
27 Diagnostics and Instrumentation 1373
Ensuring Code Quality 1374
Instrumentation 1388
Controlling Processes 1396
Summary 1398
28 Working with I/O 1399
Files and Directories 1399
Monitoring File System Activity 1407
Readers and Writers 1409
Streams: The Bread and Butter of I/O 1415
A Primer to (Named) Pipes 1434
Memory-Mapped Files in a Nutshell 1437
Overview of Other I/O Capabilities 1440
Summary 1440
29 Threading and Synchronization 1443
Using Threads 1444
Thread Pools 1474
Synchronization Primitives 1482
Summary 1511
30 Task Parallelism and Data Parallelism 1513
Pros and Cons of Threads 1514
The Task Parallel Library 1515
Task Parallelism 1520
Data Parallelism 1542
Summary 1550
31 Asynchronous Programming 1551
Why Asynchronous Programming Matters 1551
Old Asynchronous Programming Patterns 1564
Asynchronous Methods and await Expressions 1584
Behind the Scenes 1610
Advanced Topics 1634
Summary 1641
32 Introduction to Windows Runtime 1643
What Is Windows Runtime? 1643
Creating a Windows Runtime Component 1658
Overview of the Windows Runtime APIs 1667
Summary 1669
Index 1671
When you have a question about C# 5.0 or the .NET CLR, this bestselling guide has precisely the answers you need. Uniquely organized around concepts and use cases, this updated fifth edition features a reorganized section on concurrency, threading, and parallel programming—including in-depth coverage of C# 5.0’s new asynchronous functions.
Shaped by more than 20 expert reviewers, including Microsoft’s Eric Lippert, Stephen Toub, Chris Burrows, and Jon Skeet, this book has all you need to stay on track with C# 5.0. It’s widely known as the definitive reference on the language.
- Get up to speed on C# language basics, including syntax, types, and variables
- Explore advanced topics such as unsafe code and type variance
- Dig deep into LINQ via three chapters dedicated to the topic
- Learn about code contracts, dynamic programming, and parallel programming
- Work with .NET features, including reflection, assemblies, memory management, security, I/O, XML, collections, networking, and native interoperability
“C# 5.0 in a Nutshell is one of the few books I keep on my desk as a quick reference.”
—Scott Guthrie, Microsoft
“Whether you’re a novice programmer or an expert who wants to improve your knowledge of modern asynchronous programming techniques, this book has the
Table of Contents
Preface; Intended Audience; How This Book Is Organized; What You Need to Use This Book; Conventions Used in This Book; Using Code Examples; Safari® Books Online; How to Contact Us; Acknowledgments; Chapter 1: Introducing C# and the .NET Framework; 1.1 Object Orientation; 1.2 Type Safety; 1.3 Memory Management; 1.4 Platform Support; 1.5 C#’s Relationship with the CLR; 1.6 The CLR and .NET Framework; 1.7 C# and Windows Runtime; 1.8 What’s New in C# 5.0; 1.9 What’s New in C# 4.0; 1.10 What’s New in C# 3.0; Chapter 2: C# Language Basics; 2.1 A First C# Program; 2.2 Syntax; 2.3 Type Basics; 2.4 Numeric Types; 2.5 Boolean Type and Operators; 2.6 Strings and Characters; 2.7 Arrays; 2.8 Variables and Parameters; 2.9 Expressions and Operators; 2.10 Statements; 2.11 Namespaces; Chapter 3: Creating Types in C#; 3.1 Classes; 3.2 Inheritance; 3.3 The object Type; 3.4 Structs; 3.5 Access Modifiers; 3.6 Interfaces; 3.7 Enums; 3.8 Nested Types; 3.9 Generics; Chapter 4: Advanced C#; 4.1 Delegates; 4.2 Events; 4.3 Lambda Expressions; 4.4 Anonymous Methods; 4.5 try Statements and Exceptions; 4.6 Enumeration and Iterators; 4.7 Nullable Types; 4.8 Operator Overloading; 4.9 Extension Methods; 4.10 Anonymous Types; 4.11 Dynamic Binding; 4.12 Attributes; 4.13 Caller Info Attributes (C# 5); 4.14 Unsafe Code and Pointers; 4.15 Preprocessor Directives; 4.16 XML Documentation; Chapter 5: Framework Overview; 5.1 The CLR and Core Framework; 5.2 Applied Technologies; Chapter 6: Framework Fundamentals; 6.1 String and Text Handling; 6.2 Dates and Times; 6.3 Dates and Time Zones; 6.4 Formatting and Parsing; 6.5 Standard Format Strings and Parsing Flags; 6.6 Other Conversion Mechanisms; 6.7 Globalization; 6.8 Working with Numbers; 6.9 Enums; 6.10 Tuples; 6.11 The Guid Struct; 6.12 Equality Comparison; 6.13 Order Comparison; 6.14 Utility Classes; Chapter 7: Collections; 7.1 Enumeration; 7.2 The ICollection and IList Interfaces; 7.3 The Array Class; 7.4 Lists, Queues, Stacks, and Sets; 7.5 Dictionaries; 7.6 Customizable Collections and Proxies; 7.7 Plugging in Equality and Order; Chapter 8: LINQ Queries; 8.1 Getting Started; 8.2 Fluent Syntax; 8.3 Query Expressions; 8.4 Deferred Execution; 8.5 Subqueries; 8.6 Composition Strategies; 8.7 Projection Strategies; 8.8 Interpreted Queries; 8.9 LINQ to SQL and Entity Framework; 8.10 Building Query Expressions; Chapter 9: LINQ Operators; 9.1 Overview; 9.2 Filtering; 9.3 Projecting; 9.4 Joining; 9.5 Ordering; 9.6 Grouping; 9.7 Set Operators; 9.8 Conversion Methods; 9.9 Element Operators; 9.10 Aggregation Methods; 9.11 Quantifiers; 9.12 Generation Methods; Chapter 10: LINQ to XML; 10.1 Architectural Overview; 10.2 X-DOM Overview; 10.3 Instantiating an X-DOM; 10.4 Navigating and Querying; 10.5 Updating an X-DOM; 10.6 Working with Values; 10.7 Documents and Declarations; 10.8 Names and Namespaces; 10.9 Annotations; 10.10 Projecting into an X-DOM; Chapter 11: Other XML Technologies; 11.1 XmlReader; 11.2 XmlWriter; 11.3 Patterns for Using XmlReader/XmlWriter; 11.4 XmlDocument; 11.5 XPath; 11.6 XSD and Schema Validation; 11.7 XSLT; Chapter 12: Disposal and Garbage Collection; 12.1 IDisposable, Dispose, and Close; 12.2 Automatic Garbage Collection; 12.3 Finalizers; 12.4 How the Garbage Collector Works; 12.5 Managed Memory Leaks; 12.6 Weak References; Chapter 13: Diagnostics and Code Contracts; 13.1 Conditional Compilation; 13.2 Debug and Trace Classes; 13.3 Code Contracts Overview; 13.4 Preconditions; 13.5 Postconditions; 13.6 Assertions and Object Invariants; 13.7 Contracts on Interfaces and Abstract Methods; 13.8 Dealing with Contract Failure; 13.9 Selectively Enforcing Contracts; 13.10 Static Contract Checking; 13.11 Debugger Integration; 13.12 Processes and Process Threads; 13.13 StackTrace and StackFrame; 13.14 Windows Event Logs; 13.15 Performance Counters; 13.16 The Stopwatch Class; Chapter 14: Concurrency & Asynchrony; 14.1 Introduction; 14.2 Threading; 14.3 Tasks; 14.4 Principles of Asynchrony; 14.5 Asynchronous Functions in C# 5.0; 14.6 Asynchronous Patterns; 14.7 Obsolete Patterns; Chapter 15: Streams and I/O; 15.1 Stream Architecture; 15.2 Using Streams; 15.3 Stream Adapters; 15.4 Compression Streams; 15.5 Working with Zip Files; 15.6 File and Directory Operations; 15.7 File I/O in Windows Runtime; 15.8 Memory-Mapped Files; 15.9 Isolated Storage; Chapter 16: Networking; 16.1 Network Architecture; 16.2 Addresses and Ports; 16.3 URIs; 16.4 Client-Side Classes; 16.5 Working with HTTP; 16.6 Writing an HTTP Server; 16.7 Using FTP; 16.8 Using DNS; 16.9 Sending Mail with SmtpClient; 16.10 Using TCP; 16.11 Receiving POP3 Mail with TCP; 16.12 TCP in Windows Runtime; Chapter 17: Serialization; 17.1 Serialization Concepts; 17.2 The Data Contract Serializer; 17.3 Data Contracts and Collections; 17.4 Extending Data Contracts; 17.5 The Binary Serializer; 17.6 Binary Serialization Attributes; 17.7 Binary Serialization with ISerializable; 17.8 XML Serialization; Chapter 18: Assemblies; 18.1 What’s in an Assembly; 18.2 Strong Names and Assembly Signing; 18.3 Assembly Names; 18.4 Authenticode Signing; 18.5 The Global Assembly Cache; 18.6 Resources and Satellite Assemblies; 18.7 Resolving and Loading Assemblies; 18.8 Deploying Assemblies Outside the Base Folder; 18.9 Packing a Single-File Executable; 18.10 Working with Unreferenced Assemblies; Chapter 19: Reflection and Metadata; 19.1 Reflecting and Activating Types; 19.2 Reflecting and Invoking Members; 19.3 Reflecting Assemblies; 19.4 Working with Attributes; 19.5 Dynamic Code Generation; 19.6 Emitting Assemblies and Types; 19.7 Emitting Type Members; 19.8 Emitting Generic Methods and Types; 19.9 Awkward Emission Targets; 19.10 Parsing IL; Chapter 20: Dynamic Programming; 20.1 The Dynamic Language Runtime; 20.2 Numeric Type Unification; 20.3 Dynamic Member Overload Resolution; 20.4 Implementing Dynamic Objects; 20.5 Interoperating with Dynamic Languages; Chapter 21: Security; 21.1 Permissions; 21.2 Code Access Security (CAS); 21.3 Allowing Partially Trusted Callers; 21.4 The Transparency Model; 21.5 Sandboxing Another Assembly; 21.6 Operating System Security; 21.7 Identity and Role Security; 21.8 Cryptography Overview; 21.9 Windows Data Protection; 21.10 Hashing; 21.11 Symmetric Encryption; 21.12 Public Key Encryption and Signing; Chapter 22: Advanced Threading; 22.1 Synchronization Overview; 22.2 Exclusive Locking; 22.3 Locking and Thread Safety; 22.4 Non-Exclusive Locking; 22.5 Signaling with Event Wait Handles; 22.6 The Barrier Class; 22.7 Lazy Initialization; 22.8 Thread-Local Storage; 22.9 Interrupt and Abort; 22.10 Suspend and Resume; 22.11 Timers; Chapter 23: Parallel Programming; 23.1 Why PFX?; 23.2 PLINQ; 23.3 The Parallel Class; 23.4 Task Parallelism; 23.5 Working with AggregateException; 23.6 Concurrent Collections; 23.7 BlockingCollection; Chapter 24: Application Domains; 24.1 Application Domain Architecture; 24.2 Creating and Destroying Application Domains; 24.3 Using Multiple Application Domains; 24.4 Using DoCallBack; 24.5 Monitoring Application Domains; 24.6 Domains and Threads; 24.7 Sharing Data Between Domains; Chapter 25: Native and COM Interoperability; 25.1 Calling into Native DLLs; 25.2 Type Marshaling; 25.3 Callbacks from Unmanaged Code; 25.4 Simulating a C Union; 25.5 Shared Memory; 25.6 Mapping a Struct to Unmanaged Memory; 25.7 COM Interoperability; 25.8 Calling a COM Component from C#; 25.9 Embedding Interop Types; 25.10 Primary Interop Assemblies; 25.11 Exposing C# Objects to COM; Chapter 26: Regular Expressions; 26.1 Regular Expression Basics; 26.2 Quantifiers; 26.3 Zero-Width Assertions; 26.4 Groups; 26.5 Replacing and Splitting Text; 26.6 Cookbook Regular Expressions; 26.7 Regular Expressions Language Reference; Colophon;|
- Preface
- Chapter 1: Introducing C# and the .NET Framework
- Chapter 2: C# Language Basics
- Chapter 3: Creating Types in C#
- Chapter 4: Advanced C#
- Chapter 5: Framework Overview
- Chapter 6: Framework Fundamentals
- Chapter 7: Collections
- Chapter 8: LINQ Queries
- Chapter 9: LINQ Operators
- Chapter 10: LINQ to XML
- Chapter 11: Other XML Technologies
- Chapter 12: Disposal and Garbage Collection
- Chapter 13: Diagnostics and Code Contracts
- Chapter 14: Concurrency & Asynchrony
- Chapter 15: Streams and I/O
- Chapter 16: Networking
- Chapter 17: Serialization
- Chapter 18: Assemblies
- Chapter 19: Reflection and Metadata
- Chapter 20: Dynamic Programming
- Chapter 21: Security
- Chapter 22: Advanced Threading
- Chapter 23: Parallel Programming
- Chapter 24: Application Domains
- Chapter 25: Native and COM Interoperability
- Chapter 26: Regular Expressions
Michaelis, M. and Lippert, E. (2013) Essential C# 5.0 (Microsoft Windows Development), Fourth Edition, Addison-Wesley, Pearson Education, Inc
A more recent version of this book is available
Download Source Code (ZIP 579KB)
Essential C# 5.0 is a well-organized, no-fluff guide to the latest versions of C# for programmers at all levels of C# experience. Fully updated to reflect new features and programming patterns introduced with C# 5.0 and .NET 4.5, this guide shows you how to write C# code that is simple, powerful, robust, secure, and maintainable. Microsoft MVP Mark Michaelis and C# principal developer Eric Lippert provide comprehensive coverage of the entire language, offering a complete foundation for effective software development.
The authors illustrate key constructs with succinct, downloadable code examples. Graphical mind maps at the beginning of each chapter outline the material that is covered and how individual topics interrelate. This edition also includes C# Coding Guidelines that call attention to today’s best practices for writing C# code. Separate indexes of C# versions 3.0, 4.0, and 5.0 make it easy to find answers specific to whatever version of C# you are using.
Throughout, topics intended for beginners and advanced readers are clearly marked. If you’re new to C#, this guide will help you start writing significant code quickly. If you’re an experienced C# developer, you’ll gain insight into today’s most complex programming challenges and techniques as you master key C# 5.0 innovations such as async/await pattern. No matter how advanced your skills become, you’ll come to rely on this indispensable reference.
Coverage includes
- Mastering C# data types, operators, control flow, methods, and parameters
- Making the most of C# object-oriented constructs, including classes, inheritance, interfaces, and more
- Building reliable, effective exception handling into your code
- Using generics, delegates, Lambda expressions, and events to reduce code complexity
- Learning dynamic programming with reflection and attributes
- Querying virtually any type of data using LINQ with Query Expressions
- Creating custom collections that operate against business objects
- Understanding the Common Language Infrastructure and C# in the context of the .NET 4.5 development platform
- Taking advantage of declarative programming, embedded metadata, reflection, and attributes
- Thoroughly mastering multithreading and synchronization, including the new async/await paradigm
- Discussion of WinRT and programming in C# for Windows 8
- Using P/Invoke, pointers, and direct memory manipulation to interoperate with code in other languages
- Understanding how C# programs relate to the underlying runtime
Table of Contents
Figures xv
Tables xvii
Foreword xix
Preface xxiii
Acknowledgments xxxv
About the Authors xxxvii
Chapter 1: Introducing C# 1
Hello, World 2
C# Syntax Fundamentals 4
Console Input and Output 17
Chapter 2: Data Types 33
Fundamental Numeric Types 34
More Fundamental Types 43
null and void 53
Categories of Types 57
Nullable Modifier 60
Conversions between Data Types 60
Arrays 67
Chapter 3: Operators and Control Flow 85
Operators 86
Introducing Flow Control 103
Code Blocks ({}) 110
Code Blocks, Scopes, and Declaration Spaces 112
Boolean Expressions 114
Bitwise Operators (<<, >>, |, &, ^, ~) 121
Control Flow Statements, Continued 127
Jump Statements 139
C# Preprocessor Directives 145
Chapter 4: Methods and Parameters 155
Calling a Method 156
Declaring a Method 163
The using Directive 168
Returns and Parameters on Main() 172
Advanced Method Parameters 175
Recursion 184
Method Overloading 186
Optional Parameters 189
Basic Error Handling with Exceptions 194
Chapter 5: Classes 209
Declaring and Instantiating a Class 213
Instance Fields 217
Instance Methods 219
Using the this Keyword 220
Access Modifiers 227
Properties 229
Constructors 244
Static Members 255
Extension Methods 265
Encapsulating the Data 267
Nested Classes 269
Partial Classes 272
Chapter 6: Inheritance 277
Derivation 278
Overriding the Base Class 290
Abstract Classes 302
All Classes Derive from System.Object 308
Verifying the Underlying Type with the is Operator 309
Conversion Using the as Operator 310
Chapter 7: Interfaces 313
Introducing Interfaces 314
Polymorphism through Interfaces 315
Interface Implementation 320
Converting between the Implementing Class and Its Interfaces 326
Interface Inheritance 326
Multiple Interface Inheritance 329
Extension Methods on Interfaces 330
Implementing Multiple Inheritance via Interfaces 331
Versioning 334
Interfaces Compared with Classes 336
Interfaces Compared with Attributes 337
Chapter 8: Value Types 339
Structs 340
Boxing 349
Enums 358
Chapter 9: Well-Formed Types 371
Overriding object Members 371
Operator Overloading 385
Referencing Other Assemblies 393
Defining Namespaces 398
XML Comments 402
Garbage Collection 407
Resource Cleanup 410
Lazy Initialization 419
Chapter 10: Exception Handling 423
Multiple Exception Types 424
Catching Exceptions 426
General Catch Block 430
Guidelines for Exception Handling 432
Defining Custom Exceptions 435
Wrapping an Exception and Rethrowing 438
Chapter 11: Generics 443
C# without Generics 444
Introducing Generic Types 449
Constraints 462
Generic Methods 476
Covariance and Contravariance 481
Generic Internals 489
Chapter 12: Delegates and Lambda Expressions 495
Introducing Delegates 496
Lambda Expressions 506
Anonymous Methods 512
General-Purpose Delegates: System.Func and System.Action 514
Chapter 13: Events 533
Coding the Observer Pattern with Multicast Delegates 534
Events 548
Chapter 14: Collection Interfaces with Standard Query Operators 561
Anonymous Types and Implicitly Typed Local Variables 562
Collection Initializers 568
What Makes a Class a Collection: IEnumerable 571
Standard Query Operators 577
Chapter 15: LINQ with Query Expressions 613
Introducing Query Expressions 614
Query Expressions Are Just Method Invocations 632
Chapter 16: Building Custom Collections 635
More Collection Interfaces 636
Primary Collection Classes 638
Providing an Indexer 655
Returning Null or an Empty Collection 659
Iterators 660
Chapter 17: Reflection, Attributes, and Dynamic Programming 677
Reflection 678
Attributes 688
Programming with Dynamic Objects 714
Chapter 18: Multithreading 727
Multithreading Basics 730
Working with System.Threading 737
Asynchronous Tasks 745
Canceling a Task 764
The Task-Based Asynchronous Pattern in C# 5.0 770
Executing Loop Iterations in Parallel 794
Running LINQ Queries in Parallel 804
Chapter 19: Thread Synchronization 811
Why Synchronization? 813
Timers 841
Chapter 20: Platform Interoperability and Unsafe Code 845
Using the Windows Runtime Libraries from C# 846
Platform Invoke 849
Pointers and Addresses 862
Executing Unsafe Code via a Delegate 872
Chapter 21: The Common Language Infrastructure 875
Defining the Common Language Infrastructure (CLI) 876
CLI Implementations 877
C# Compilation to Machine Code 879
Runtime 881
Application Domains 887
Assemblies, Manifests, and Modules 887
Common Intermediate Language (CIL) 890
Common Type System (CTS) 891
Common Language Specification (CLS) 891
Base Class Library (BCL) 892
Metadata 892
Appendix A: Downloading and Installing the C# Compiler and CLI Platform 897
Microsoft’s .NET 897
Appendix B: Tic-Tac-Toe Source Code Listing 901
Appendix C: Interfacing with Mutithreading Patterns Prior to the TPL and C# 5.0 907
Asynchronous Programming Model 908
Asynchronous Delegate Invocation 921
The Event-Based Asynchronous Pattern (EAP) 924
Background Worker Pattern 928
Dispatching to the Windows UI 932
Appendix D: Timers Prior to the Async/Await Pattern of C# 5.0 937
Index 943
Index of C# 5.0 Topics 974
Index of C# 4.0 Topics 975
Index of C# 3.0 Topics 984
Rowe, G. W. (2004) From Java to C#, Addison-Wesley, Pearson Education
Download eBook PDF (PDF 25,847KB)
Download Source Code (ZIP 1,237KB)
C# (‘C Sharp’) is an object-oriented, network-enabled programming language, developed expressly for Microsoft’s .Net platform. C# provides the features that are most important to programmers: object-orientation, graphics, GUI components, multimedia, internet-based client/server networking and distributed computing. This book teaches C# to students who have already completed a course on Java/object oriented programming. This book will assume familiarity with object oriented programming basics, and only reviews these concepts when their C# implementations are discussed. The book starts by discussing the nuts and bolts of the C# language before delving into the area of the .Net libraries of code. It then moves on to GUI programming showing how GUI programs are created, and how to populate them with graphics. Advanced topics such as networking, using C# to interface with databases, and using C# with ASP to produce interactive web pages, are covered at the end of the book. The book will contain complete working programs and exercises at the end of each chapter.
Table of Contents
Preface
Introduction to C# and .NET
Classes and objects
Data, expressions and statements
Inside C# objects
C# classes – advanced features
Inheritance Exceptions
Events and delegates
GUI programming with Windows Forms
Graphics
Databases
XML
ASP.NET
Stellman, A. and Greene, J. (2013) Head First C#, Third Edition, O’Reilly Media, Inc.
Download eBook PDF (PDF 75,162KB)
Download Source Code (ZIP 154,155KB)
Link to further downloads: http://shop.oreilly.com/product/0636920027812.do
Companion Web Site: https://hfcsharp.codeplex.com/
Head First C# is a complete learning experience for learning how to program with C#, XAML, the .NET Framework, and Visual Studio. Fun and highly visual, this introduction to C# is designed to keep you engaged and entertained from first page to last. Updated for Windows 8.1 and Visual Studio 2013, and includes projects for all previous versions of Windows (included in the book, no additional downloading or printing required).
You’ll build a fully functional video game in the opening chapter, and then learn how to use classes and object-oriented programming, draw graphics and animation, and query data with LINQ and serialize it to files. And you’ll do it all by creating games, solving puzzles, and doing hands-on projects. By the time you’re done, you’ll be a solid C# programmer—and you’ll have a great time along the way!
- Create a fun arcade game in the first chapter, and build games and other projects throughout the book
- Learn how to use XAML to design attractive and interactive pages and windows
- Build modern Windows Store apps using the latest Microsoft technology
- Learn WPF (Windows Presentation Foundation) using the downloadable WPF Learner’s Guide
- Using the Model-View-ViewModel (MVVM) pattern to create robust architecture
- Build a bonus Windows Phone project and run it in the Visual Studio Windows Phone emulator
Projects in the book work with all editions of Visual Studio, including the free Express editions.
Table of Contents
; Advance Praise for Head First C#; Praise for other Head First books; ; How to Use this Book: Intro; Who is this book for?; We know what you’re thinking.; And we know what your brain is thinking; Metacognition: thinking about thinking; Here’s what WE did; Here’s what You can do to bend your brain into submission; Read me; What version of Windows are you using?; The technical review team; Acknowledgments; Safari® Books Online; Chapter 1: Start Building with C#: Build something cool, fast!; 1.1 Why you should learn C#; 1.2 C# and the Visual Studio IDE make lots of things easy; 1.3 What you do in Visual Studio…; 1.4 What Visual Studio does for you…; 1.5 Aliens attack!; 1.6 Only you can help save the Earth; 1.7 Here’s what you’re going to build; 1.8 Start with a blank application; 1.9 Set up the grid for your page; 1.10 Add controls to your grid; 1.11 Use properties to change how the controls look; 1.12 Controls make the game work; 1.13 You’ve set the stage for the game; 1.14 What you’ll do next; 1.15 Add a method that does something; 1.16 Fill in the code for your method; 1.17 Finish the method and run your program; 1.18 Here’s what you’ve done so far; 1.19 Add timers to manage the gameplay; 1.20 Make the Start button work; 1.21 Run the program to see your progress; 1.22 Add code to make your controls interact with the player; 1.23 Dragging humans onto enemies ends the game; 1.24 Your game is now playable; 1.25 Make your enemies look like aliens; 1.26 Add a splash screen and a tile; 1.27 Publish your app; 1.28 Use the Remote Debugger to sideload your app; 1.29 Start remote debugging; Chapter 2: It’s all Just Code: Under the hood; 2.1 When you’re doing this…; 2.2 …the IDE does this; 2.3 Where programs come from; 2.4 The IDE helps you code; 2.5 Anatomy of a program; 2.6 Two classes can be in the same namespace; 2.7 Your programs use variables to work with data; 2.8 C# uses familiar math symbols; 2.9 Use the debugger to see your variables change; 2.10 Loops perform an action over and over; 2.11 if/else statements make decisions; 2.12 Build an app from the ground up; 2.13 Make each button do something; 2.14 Set up conditions and see if they’re true; 2.15 Windows Desktop apps are easy to build; 2.16 Rebuild your app for Windows Desktop; 2.17 Your desktop app knows where to start; 2.18 You can change your program’s entry point; 2.19 When you change things in the IDE, you’re also changing your code; Chapter 3: Objects: Get Oriented!: Making code make sense; 3.1 How Mike thinks about his problems; 3.2 How Mike’s car navigation system thinks about his problems; 3.3 Mike’s Navigator class has methods to set and modify routes; 3.4 Use what you’ve learned to build a program that uses a class; 3.5 Mike gets an idea; 3.6 Mike can use objects to solve his problem; 3.7 You use a class to build an object; 3.8 When you create a new object from a class, it’s called an instance of that class; 3.9 A better solution…brought to you by objects!; 3.10 An instance uses fields to keep track of things; 3.11 Let’s create some instances!; 3.12 Thanks for the memory; 3.13 What’s on your program’s mind; 3.14 You can use class and method names to make your code intuitive; 3.15 Give your classes a natural structure; 3.16 Class diagrams help you organize your classes so they make sense; 3.17 Build a class to work with some guys; 3.18 Create a project for your guys; 3.19 Build a form to interact with the guys; 3.20 There’s an easier way to initialize objects; 3.21 A few ideas for designing intuitive classes; Chapter 4: Types and References: It’s 10:00. Do you know where your data is?; 4.1 The variable’s type determines what kind of data it can store; 4.2 A variable is like a data to-go cup; 4.3 10 pounds of data in a 5-pound bag; 4.4 Even when a number is the right size, you can’t just assign it to any variable; 4.5 When you cast a value that’s too big, C# will adjust it automatically; 4.6 C# does some casting automatically; 4.7 When you call a method, the arguments must be compatible with the types of the parameters; 4.8 Debug the mileage calculator; 4.9 Combining = with an operator; 4.10 Objects use variables, too; 4.11 Refer to your objects with reference variables; 4.12 References are like labels for your object; 4.13 If there aren’t any more references, your object gets garbage-collected; 4.14 Multiple references and their side effects; 4.15 Two references means TWO ways to change an object’s data; 4.16 A special case: arrays; 4.17 Arrays can contain a bunch of reference variables, too; 4.18 Welcome to Sloppy Joe’s Budget House o’ Discount Sandwiches!; 4.19 Objects use references to talk to each other; 4.20 Where no object has gone before; 4.21 Build a typing game; 4.22 Controls are objects, just like any other object; C# Lab: A Day at the Races; Chapter 5: Encapsulation: Keep your privates… Private; 5.1 Kathleen is an event planner; 5.2 What does the estimator do?; 5.3 You’re going to build a program for Kathleen; 5.4 Kathleen’s test drive; 5.5 Each option should be calculated individually; 5.6 It’s easy to accidentally misuse your objects; 5.7 Encapsulation means keeping some of the data in a class private; 5.8 Use encapsulation to control access to your class’s methods and fields; 5.9 But is the RealName field REALLY protected?; 5.10 Private fields and methods can only be accessed from inside the class; 5.11 A few ideas for encapsulating classes; 5.12 Encapsulation keeps your data pristine; 5.13 Properties make encapsulation easier; 5.14 Build an application to test the Farmer class; 5.15 Use automatic properties to finish the class; 5.16 What if we want to change the feed multiplier?; 5.17 Use a constructor to initialize private fields; Chapter 6: Inheritance: Your object’s family tree; 6.1 Kathleen does birthday parties, too; 6.2 We need a BirthdayParty class; 6.3 Build the Part y Planner version 2.0; 6.4 One more thing…can you add a $100 fee for parties over 12?; 6.5 When your classes use inheritance, you only need to write your code once; 6.6 Build up your class model by starting general and getting more specific; 6.7 How would you design a zoo simulator?; 6.8 Use inheritance to avoid duplicate code in subclasses; 6.9 Different animals make different noises; 6.10 Think about how to group the animals; 6.11 Create the class hierarchy; 6.12 Every subclass extends its base class; 6.13 Use a colon to inherit from a base class; 6.14 We know that inheritance adds the base class fields, properties, and methods to the subclass…; 6.15 A subclass can override methods to change or replace methods it inherited; 6.16 Any place where you can use a base class, you can use one of its subclasses instead; 6.17 A subclass can hide methods in the superclass; 6.18 Use the override and virtual keywords to inherit behavior; 6.19 A subclass can access its base class using the base keyword; 6.20 When a base class has a constructor, your subclass needs one, too; 6.21 Now you’re ready to finish the job for Kathleen!; 6.22 Build a beehive management system; 6.23 How you’ll build the beehive management system; 6.24 Use inheritance to extend the bee management system; Chapter 7: Interfaces and Abstract Classes: Making classes keep their promises; 7.1 Let’s get back to bee-sics; 7.2 We can use inheritance to create classes for different types of bees; 7.3 An interface tells a class that it must implement certain methods and properties; 7.4 Use the interface keyword to define an interface; 7.5 Now you can create an instance of NectarStinger that does both jobs; 7.6 Classes that implement interfaces have to include ALL of the interface’s methods; 7.7 Get a little practice using interfaces; 7.8 You can’t instantiate an interface, but you can reference an interface; 7.9 Interface references work just like object references; 7.10 You can find out if a class implements a certain interface with “is”; 7.11 Interfaces can inherit from other interfaces; 7.12 The RoboBee 4000 can do a worker bee’s job without using valuable honey; 7.13 is tells you what an object implements; as tells the compiler how to treat your object; 7.14 A CoffeeMaker is also an Appliance; 7.15 Upcasting works with both objects and interfaces; 7.16 Downcasting lets you turn your appliance back into a coffee maker; 7.17 Upcasting and downcasting work with interfaces, too; 7.18 There’s more than just public and private; 7.19 Access modifiers change visibility; 7.20 Some classes should never be instantiated; 7.21 An abstract class is like a cross between a class and an interface; 7.22 Like we said, some classes should never be instantiated; 7.23 An abstract method doesn’t have a body; 7.24 Polymorphism means that one object can take many different forms; Chapter 8: Enums and Collections: Storing lots of data; 8.1 Strings don’t always work for storing categories of data; 8.2 Enums let you work with a set of valid values; 8.3 Enums let you represent numbers with names; 8.4 We could use an array to create a deck of cards…; 8.5 Arrays are hard to work with; 8.6 Lists make it easy to store collections of…anything; 8.7 Lists are more flexible than arrays; 8.8 Lists shrink and grow dynamically; 8.9 Generics can store any type; 8.10 Collection initializers are similar to object initializers; 8.11 Let’s create a List of Ducks; 8.12 Lists are easy, but SORTING can be tricky; 8.13 IComparable helps your list sort its ducks; 8.14 Use IComparer to tell your List how to sort; 8.15 Create an instance of your comparer object; 8.16 IComparer can do complex comparisons; 8.17 Overriding a ToString() method lets an object describe itself; 8.18 Update your foreach loops to let your Ducks and Cards print themselves; 8.19 You can upcast an entire list using IEnumerable; 8.20 You can build your own overloaded methods; 8.21 Use a dictionary to store keys and values; 8.22 The dictionary functionality rundown; 8.23 Build a program that uses a dictionary; 8.24 And yet MORE collection types…; 8.25 A queue is FIFO―First In, First Out; 8.26 A stack is LIFO―Last In, First Out; Chapter 9: Reading and Writing Files: Save the last byte for me!; 9.1 .NET uses streams to read and write data; 9.2 Different streams read and write different things; 9.3 A FileStream reads and writes bytes to a file; 9.4 Write text to a file in three simple steps; 9.5 The Swindler launches another diabolical plan; 9.6 Reading and writing using two objects; 9.7 Data can go through more than one stream; 9.8 Use built-in objects to pop up standard dialog boxes; 9.9 Dialog boxes are just another WinForms control; 9.10 Dialog boxes are objects, too; 9.11 Use the built-in File and Directory classes to work with files and directories; 9.12 Use file dialogs to open and save files (all with just a few lines of code); 9.13 IDisposable makes sure your objects are disposed of properly; 9.14 Avoid filesystem errors with using statements; 9.15 Trouble at work; 9.16 Writing files usually involves making a lot of decisions; 9.17 Use a switch statement to choose the right option; 9.18 Use a switch statement to let your deck of cards read from a file or write itself out to one; 9.19 Add an overloaded Deck() constructor that reads a deck of cards in from a file; 9.20 What happens to an object when it’s serialized?; 9.21 But what exactly IS an object’s state? What needs to be saved?; 9.22 When an object is serialized, all of the objects it refers to get serialized, too…; 9.23 Serialization lets you read or write a whole object graph all at once; 9.24 If you want your class to be serializable, mark it with the [Serializable] attribute; 9.25 Let’s serialize and deserialize a deck of cards; 9.26 .NET uses Unicode to store characters and text; 9.27 C# can use byte arrays to move data around; 9.28 Use a BinaryWriter to write binary data; 9.29 You can read and write serialized files manually, too; 9.30 Find where the files differ, and use that information to alter them; 9.31 Working with binary files can be tricky; 9.32 Use file streams to build a hex dumper; 9.33 StreamReader and StreamWriter will do just fine (for now); 9.34 Use Stream.Read() to read bytes from a stream; C# Lab: The Quest; Chapter 10: Designing Windows Store Apps with XAML: Taking your apps to the next level; 10.1 Brian’s running Windows 8; 10.2 Windows Forms use an object graph set up by the IDE; 10.3 Use the IDE to explore the object graph; 10.4 Windows Store apps use XAML to create UI objects; 10.5 Redesign the Go Fish! form as a Windows Store app page; 10.6 Page layout starts with controls; 10.7 Rows and columns can resize to match the page size; 10.8 Use the grid system to lay out app pages; 10.9 Data binding connects your XAML pages to your classes; 10.10 XAML controls can contain text…and more; 10.11 Use data binding to build Sloppy Joe a better menu; 10.12 Use static resources to declare your objects in XAML; 10.13 Use a data template to display objects; 10.14 INotifyPropertyChanged lets bound objects send updates; 10.15 Modify MenuMaker to notify you when the GeneratedDate property changes; Chapter 11: Async, Await, and Data Contract Serialization: Pardon the interruption; 11.1 Brian runs into file trouble; 11.2 Windows Store apps use await to be more responsive; 11.3 Use the FileIO class to read and write files; 11.4 Build a slightly less simple text editor; 11.5 A data contract is an abstract definition of your object’s data; 11.6 Use async methods to find and open files; 11.7 KnownFolders helps you access high-profile folders; 11.8 The whole object graph is serialized to XML; 11.9 Stream some Guy objects to XML files; 11.10 Take your Guy Serializer for a test drive; 11.11 Use a Task to call one async method from another; 11.12 Build Brian a new Excuse Manager app; 11.13 Separate the page, excuse, and Excuse Manager; 11.14 Create the main page for the Excuse Manager; 11.15 Add the app bar to the main page; 11.16 Build the ExcuseManager class; 11.17 Add the code-behind for the page; Chapter 12: Exception Handling: Putting out fires gets old; 12.1 Brian needs his excuses to be mobile; 12.2 When your program throws an exception, .NET generates an Exception object; 12.3 Brian’s code did something unexpected; 12.4 All exception objects inherit from Exception; 12.5 The debugger helps you track down and prevent exceptions in your code; 12.6 Use the IDE’s debugger to ferret out exactly what went wrong in the Excuse Manager; 12.7 Uh oh―the code’s still got problems…; 12.8 Handle exceptions with try and catch; 12.9 Use the debugger to follow the try/catch flow; 12.10 If you have code that ALWAYS should run, use a finally block; 12.11 Use the Exception object to get information about the problem; 12.12 Use more than one catch block to handle multiple types of exceptions; 12.13 One class throws an exception that a method in another class can catch; 12.14 Bees need an OutOfHoney exception; 12.15 An easy way to avoid a lot of problems: using gives you try and finally for free; 12.16 Exception avoidance: implement IDisposable to do your own cleanup; 12.17 The worst catch block EVER: catch-all plus comments; 12.18 Temporary solutions are OK (temporarily); 12.19 A few simple ideas for exception handling; 12.20 Brian finally gets his vacation…; Chapter 13: Captain Amazing: The Death of the Object; 13.1 Your last chance to DO something… your object’s finalizer; 13.2 When EXACTLY does a finalizer run?; 13.3 Dispose() works with using; finalizers work with garbage collection; 13.4 Finalizers can’t depend on stability; 13.5 Make an object serialize itself in its Dispose(); 13.6 A struct looks like an object…; 13.7 …but isn’t an object; 13.8 Values get copied; references get assigned; 13.9 Structs are value types; objects are reference types; 13.10 The stack vs. the heap: more on memory; 13.11 Use out parameters to make a method return more than one value; 13.12 Pass by reference using the ref modifier; 13.13 Use optional parameters to set default values; 13.14 Use nullable types when you need nonexistent values; 13.15 Nullable types help you make your programs more robust; 13.16 “Captain” Amazing…not so much; 13.17 Extension methods add new behavior to EXISTING classes; 13.18 Extending a fundamental type: string; Chapter 14: Querying Data and Building Apps With Linq: Get control of your data; 14.1 Jimmy’s a Captain Amazing super-fan…; 14.2 …but his collection’s all over the place; 14.3 LINQ can pull data from multiple sources; 14.4 .NET collections are already set up for LINQ; 14.5 LINQ makes queries easy; 14.6 LINQ is simple, but your queries don’t have to be; 14.7 Jimmy could use some help; 14.8 Start building Jimmy an app; 14.9 Use the new keyword to create anonymous types; 14.10 LINQ is versatile; 14.11 Add the new queries to Jimmy’s app; 14.12 LINQ can combine your results into groups; 14.13 Combine Jimmy’s values into groups; 14.14 Use join to combine two collections into one sequence; 14.15 Jimmy saved a bunch of dough; 14.16 Use semantic zoom to navigate your data; 14.17 Add semantic zoom to Jimmy’s app; 14.18 You made Jimmy’s day; 14.19 The IDE’s Split App template helps you build apps for navigating data; Chapter 15: Events and Delegates: What your code does when you’re not looking; 15.1 Ever wish your objects could think for themselves?; 15.2 But how does an object KNOW to respond?; 15.3 When an EVENT occurs…objects listen; 15.4 One object raises its event, others listen for it…; 15.5 Then, the other objects handle the event; 15.6 Connecting the dots; 15.7 The IDE generates event handlers for you automatically; 15.8 Generic EventHandlers let you define your own event types; 15.9 Windows Forms use many different events; 15.10 One event, multiple handlers; 15.11 Windows Store apps use events for process lifetime management; 15.12 Add process lifetime management to Jimmy’s comics; 15.13 XAML controls use routed events; 15.14 Create an app to explore routed events; 15.15 Connecting event senders with event listeners; 15.16 A delegate STANDS IN for an actual method; 15.17 Delegates in action; 15.18 An object can subscribe to an event…; 15.19 Use a callback to control who’s listening; 15.20 A callback is just a way to use delegates; 15.21 MessageDialog uses the callback pattern; 15.22 Use delegates to use the Windows settings charm; Chapter 16: Architecting Apps with the mvvm Pattern: Great apps on the inside and outside; 16.1 The Head First Basketball Conference needs an app; 16.2 But can they agree on how to build it?; 16.3 Do you design for binding or for working with data?; 16.4 MVVM lets you design for binding and data; 16.5 Use the MVVM pattern to start building the basketball roster app; 16.6 User controls let you create your own controls; 16.7 The ref needs a stopwatch; 16.8 MVVM means thinking about the state of the app; 16.9 Start building the stopwatch app’s Model; 16.10 Events alert the rest of the app to state changes; 16.11 Build the view for a simple stopwatch; 16.12 Add the stopwatch ViewModel; 16.13 Finish the stopwatch app; 16.14 Converters automatically convert values for binding; 16.15 Converters can work with many different types; 16.16 Styles set properties on multiple controls; 16.17 Use a resource dictionary to share resources between pages; 16.18 Visual states make controls respond to changes; 16.19 Use DoubleAnimation to animate double values; 16.20 Use object animations to animate object values; 16.21 Build an analog stopwatch using the same ViewModel; 16.22 UI controls can be instantiated with C# code, too; 16.23 C# can build “real” animations, too; 16.24 Create a user control to animate a picture; 16.25 Make your bees fly around a page; 16.26 Use ItemsPanelTemplate to bind controls to a Canvas; 16.27 Congratulations! (But you’re not done yet…); C# Lab Invaders; Leftovers: The top 10 things we wanted to include in this book; #1. There’s so much more to Windows Store; #2. The Basics; #3. Namespaces and assemblies; #4. Use BackgroundWorker to make your WinForms responsive; #5. The Type class and GetType(); #6. Equality, IEquatable, and Equals(); #7. Using yield return to create enumerable objects; #8. Refactoring; #9. Anonymous types, anonymous methods, and lambda expressions; #10. LINQ to XML; Did you know that C# and the .NET Framework can…; Windows Presentation Foundation: WPF Learner’s Guide to Head First C#; Why you should learn WPF; Build WPF projects in Visual Studio; How to use this appendix; Chapter 1; Chapter 2; Chapter 10; Chapter 11; Chapter 12; Chapter 14; Chapter 15; Chapter 16;|
- How to Use this Book: Intro
- Chapter 1: Start Building with C#: Build something cool, fast!
- Chapter 2: It’s all Just Code: Under the hood
- Chapter 3: Objects: Get Oriented!: Making code make sense
- Chapter 4: Types and References: It’s 10:00. Do you know where your data is?
- C# Lab: A Day at the Races
- Chapter 5: Encapsulation: Keep your privates… Private
- Chapter 6: Inheritance: Your object’s family tree
- Chapter 7: Interfaces and Abstract Classes: Making classes keep their promises
- Chapter 8: Enums and Collections: Storing lots of data
- Chapter 9: Reading and Writing Files: Save the last byte for me!
- C# Lab: The Quest
- Chapter 10: Designing Windows Store Apps with XAML: Taking your apps to the next level
- Chapter 11: Async, Await, and Data Contract Serialization: Pardon the interruption
- Chapter 12: Exception Handling: Putting out fires gets old
- Chapter 13: Captain Amazing: The Death of the Object
- Chapter 14: Querying Data and Building Apps With Linq: Get control of your data
- Chapter 15: Events and Delegates: What your code does when you’re not looking
- Chapter 16: Architecting Apps with the mvvm Pattern: Great apps on the inside and outside
- C# Lab Invaders
- Leftovers: The top 10 things we wanted to include in this book
- Windows Presentation Foundation: WPF Learner’s Guide to Head First C#