Эксоцман
на главную поиск contacts

Learning C# 2005, Second Edition

Опубликовано на портале: 15-11-2006
Изд-во: O'Reilly Media, 2006, 552 с.
Completely revised to cover C# 2.0 and Visual Basic 2005, this introductory guide offers a thorough introduction to Microsoft's premier .NET language. Discover how to develop various kinds of web services and applications--including those that work with databases. More than 200 questions and programming exercises make mastering the essentials of the C# language easy and fun.

Preface

1. C# and .NET Programming 1

C# 2005 and .NET 2.0 2

The .NET Platform 2

The .NET 2.0 Framework 2

The C# Language 3

The Structure of C# Applications 4

The Development Environment 5

What’s in a Program? 8

Your First Program: Hello World 8

The Compiler 9

Examining Your First Program 10

Summary 14

Quiz 15

Exercise 15

2. Visual Studio 2005 16

Before You Read Further 18

Start Page 18

Projects and Solutions 18

Web Sites 20

Templates 21

Inside the Integrated Development Environment 21

Building and Running 24

Menus and Toolbars 25

File Menu 25

Edit Menu 25

View Menu 32

Refactor Menu 37

Project Menu 37

Build Menu 38

Debug Menu 38

Data Menu 38

Format Menu 38

Tools Menu 38

Window Menu 39

Help Menu 40

Summary 40

Quiz 41

Exercises 41

3. C# Language Fundamentals  42

Statements 42

Types 43

Numeric Types 44

Non-Numeric Types: char and bool 45

Types and Compiler Errors 46

Variables 47

Definite Assignment 49

Constants 50

Literal Constants 50

Symbolic Constants 50

Enumerations 52

Strings 55

Expressions 55

Whitespace 56

Summary 57

Quiz 58

Exercises 58

4. Operators 59

The Assignment Operator (=) 59

Mathematical Operators 60

Simple Arithmetical Operators (+, -, *, / ) 60

The modulus Operator (%) 61

Increment and Decrement Operators 62

Calculate and Reassign Operators 62

Increment or Decrement by 1 63

The Prefix and Postfix Operators 63

Relational Operators 65

Use of Logical Operators with Conditionals 66

The Conditional Operator 67

Operator Precedence 67

Summary 69

Quiz 70

Exercises 70

5. Branching 72

Unconditional Branching Statements 73

Conditional Branching Statements 74

if Statements 75

Single-Statement if Blocks 76

Short-Circuit Evaluation 80

if . . . else Statements 81

Nested if Statements 82

switch Statements 84

Falling-Through and Jumping-To Cases 87

Switch on string Statements 88

Iteration (Looping) Statements 89

Creating Loops with goto 89

The while Loop 91

The do . . . while Loop 92

The for Loop 93

Summary 101

Quiz 102

Exercises 103

6. Object-Oriented Programming 104

Creating Models 106

Classes and Objects 106

Defining a Class 107

Class Relationships 108

The Three Pillars of Object-Oriented Programming 109

Encapsulation 109

Specialization 110

Polymorphism 111

Object-Oriented Analysis and Design 111

Summary 113

Quiz 114

Exercises 114

7. Classes and Objects 115

Defining Classes 116

Instantiating Objects 117

Creating a Time Class 118

Access Modifiers 121

Method Arguments 121

Constructors 123

Initializers 125

The this Keyword 127

Static and Instance Members 128

Invoking Static Methods 129

Using Static Fields 131

Destroying Objects 133

Memory Allocation: The Stack Versus the Heap 135

Summary 140

Quiz 142

Exercises 143

8. Inside Methods 144

Overloading Methods 144

Encapsulating Data with Properties 147

The get Accessor 151

The set Accessor 151

Returning Multiple Values 152

Passing Value Types by Reference 154

out Parameters and Definite Assignment 157

Summary 158

Quiz 158

Exercises 159

9. Basic Debugging 160

Setting a Breakpoint 160

Using the Debug Menu to Set Your Breakpoint 163

Setting Conditions and Hit Counts 163

Examining Values: The Autos and Locals Windows 164

Set Your Watch 166

The Call Stack 169

Summary 169

Quiz 170

Exercises 171

10. Arrays 174

Using Arrays 174

Declaring Arrays 175

Understanding Default Values 176

Accessing Array Elements 176

The foreach Statement 179

Initializing Array Elements 179

The params Keyword 180

Multidimensional Arrays 181

Rectangular Arrays 182

Jagged Arrays 185

Array Methods 188

Sorting Arrays 189

Summary 191

Quiz 192

Exercises 192

11. Inheritance and Polymorphism 194

Specialization and Generalization 194

Inheritance 197

Implementing Inheritance 197

Calling Base Class Constructors 199

Controlling Access 200

Polymorphism 201

Creating Polymorphic Types 201

Versioning with new and override 205

Abstract Classes 207

Sealed Classes 210

The Root of All Classes: Object 211

Boxing and Unboxing Types 213

Boxing Is Implicit 213

Unboxing Must Be Explicit 214

Avoiding Boxing with Generics 215

Summary 215

Quiz 216

Exercises 217

12. Operator Overloading 218

Using the operator Keyword 219

Creating Useful Operators 222

The Equals Operator 223

Conversion Operators 229

Summary 234

Quiz 234

Exercises 235

13. Interfaces  236

Implementing an Interface 237

Defining the Interface 240

Implementing the Interface on the Client 241

Implementing More than One Interface 242

Casting to an Interface 245

The is and as Operators 246

Extending Interfaces 251

Combining Interfaces 254

Overriding Interface Implementations 255

Explicit Interface Implementation 260

Summary 263

Quiz 264

Exercises 264

14. Generics and Collections 266

Generics 266

Collection Interfaces 267

Creating Your Own Collections 267

Indexers and Assignment 271

Indexing on Other Values 272

Generic Collection Interfaces 275

The IEnumerable<T> Interface 276

Framework Generic Collections 280

Generic Lists: List<T> 280

Generic Queues 291

Generic Stacks 294

Dictionaries 297

Summary 300

Quiz 301

Exercises 301

15. Strings 302

Creating Strings 303

String Literals 303

Escape Characters 303

Verbatim Strings 304

The ToString( ) Method 304

Manipulating Strings 305

Comparing Strings 305

Concatenating Strings 307

Copying Strings 308

Testing for Equality 310

Other Useful String Methods 311

Finding Substrings 314

Splitting Strings 317

The StringBuilder Class 319

Regular Expressions 321

The Regex Class 322

Summary 324

Quiz 325

Exercises 325

16. Throwing and Catching Exceptions 327

Bugs, Errors, and Exceptions 328

Throwing Exceptions 328

Searching for an Exception Handler 328

The throw Statement 329

The try and catch Statements 331

How the Call Stack Works 333

Creating Dedicated catch Statements 335

The finally Statement 337

Exception Class Methods and Properties 339

Custom Exceptions 343

Summary 345

Quiz 346

Exercises 346

17. Delegates and Events  347

Delegates 348

Using Delegates to Specify Methods at Runtime 348

Multicasting 357

Events 357

Publishing and Subscribing 358

Events and Delegates 359

Solving Delegate Problems with Events 366

The event Keyword 367

Using Anonymous Methods 371

Summary 371

Quiz 372

Exercises 373

18. Creating Windows Applications 374

Creating a Simple Windows Form 374

Using the Visual Studio Designer 374

The partial Keyword 380

Creating a Real-World Application 380

Creating the Basic UI Form 382

Populating the TreeView Controls 383

Handling TreeView Events 388

Implementing the Copy Button Event 391

Handling the Delete Button Event 395

XML Documentation Comments 405

Summary 407

Quiz 408

Exercises 408

19. Programming ASP.NET Applications  410

Understanding Web Forms 410

Web Form Events 412

Postback Versus Non-Postback Events 413

State 413

Creating a Web Form 414

Code-Behind Files 415

Enabling Debugging 417

Adding Controls 417

Server Controls 419

Data Binding 421

Adding Controls and Events 424

Summary 430

Quiz 431

Exercises 431

Appendix: Answers to Quizzes and Exercises 435

Index 511


Ключевые слова

См. также:
Tim Patrick, John Clark Craig
[Книга]
Jesse Liberty
[Книга]
Jesse Liberty
[Книга]
Jesse Liberty
[Книга]
Ray Lischner
[Книга]
Jeff Cogswell, Jonathan Turkanis, Christopher Diggins, Ryan Stephens
[Книга]
Chris Shiflett
[Книга]