C# 24-Hour Trainer, 2E
Buy Rights Online Buy Rights

Rights Contact Login For More Details

  • Wiley

More About This Title C# 24-Hour Trainer, 2E

English

Quickly learn to program in C# programming with this unique book and video package

C# 24-Hour Trainer, 2nd Edition is your quick and easy guide to programming in C#, even if you have no programming experience at all. Updated to align with the latest C# standard, this book is your comprehensive beginner's guide, with each lesson supplemented by a video, for over ten hours of video training. Each chapter focuses on a specific concept or technique, with detailed, easy-to-follow explanation followed by a hands-on exercise. The goals of each exercise are outlined in advance to help you understand what you're working toward, and step-by-step instructions walk you through the operation from start to finish. Complex areas are clarified with specifically highlighted pointers that head off confusion, and additional exercises are provided so you can practice your new skills. Full instructor ancillaries are included to make this guide classroom ready, and the author's own website offers ongoing support.

C# has become one of the most popular programming languages in the world, with millions of lines of code used in businesses and applications of all types and sizes. This book helps you dive right in so you can start programming right away.

  • Start right in with the latest C# standard
  • Learn at your own pace, with hands-on practice
  • Clear up confusion and work around common obstacles
  • Build your own Windows, .NET, and mobile applications

C# has become a increasingly popular and in-demand programming skillsets. If you've decided to learn C#, this 24-Hour Trainer is your ultimate guide.

English

Rod Stephens is a programming guru, C# specialist, and the author of 30 programming books covering C#, Java, VB, and more. His C# Helper website (www.csharphelper.com) is a trusted resource in the programming community, receiving tens of thousands of monthly hits for the helpful tips, tricks, and code for professional C# programmers. Rod has applied his expertise in diverse fields, from communications to professional sports training.

English

INTRODUCTION xxvii

PART I: THE VISUAL STUDIO IDE AND CONTROLS

LESSON 1: GETTING STARTED WITH THE VISUAL STUDIO IDE 3

Installing C# 4

Configuring the IDE 6

Building Your First Program 7

Copying Projects 12

Exploring the IDE 13

Try It 16

Lesson Requirements 17

Hints 17

Step-by-Step 17

Exercises 20

LESSON 2: CREATING CONTROLS 21

Understanding Controls 21

Properties 22

Methods 22

Events 22

Creating Controls 23

Setting Control Properties 24

Control Names 26

Popular Properties 27

Modifying Properties in Code 28

Arranging Controls 30

Snap Lines 30

Arrow Keys 31

The Format Menu and Layout Toolbar 31

WPF Controls 32

Try It 32

Lesson Requirements 33

Hints 33

Step-by-Step 33

Exercises 37

LESSON 3: MAKING CONTROLS ARRANGE THEMSELVES 43

Restricting Form Size 44

Using Anchor Properties 44

Using Dock Properties 47

Layout Containers 48

Windows Forms Controls 48

WPF Controls 49

Try It 50

Lesson Requirements 51

Hints 51

Step-by-Step 52

Exercises 52

LESSON 4: HANDLING EVENTS 57

Making Event Handlers 57

Using Event Parameters 59

Setting Scrollbar Properties 60

Tracking Mouse Movement 61

Moving the Mouse Picture 61

Removing Event Handlers 62

Adding and Removing Event Handlers in Code 62

Useful Events 63

Try It 65

Lesson Requirements 65

Hints 65

Step-by-Step 66

Exercises 66

LESSON 5: MAKING MENUS 73

Creating Menus 73

Setting Menu Properties 75

Handling Menu Events 76

Creating Context Menus 77

WPF Menus 78

WPF Context Menus 79

WPF Commanding 79

Try It 80

Lesson Requirements 80

Hints 81

Step-by-Step 81

Exercises 83

LESSON 6: MAKING TOOL STRIPS AND STATUS STRIPS 89

Using Tool Strips 89

Using Tool Strip Containers 91

Using Status Strips 92

Try It 93

Lesson Requirements 93

Hints 95

Step-by-Step 95

Exercises 98

LESSON 7: USING RICHTEXTBOXES 103

Using RichTextBox Properties 103

Giving the User Control 105

Using RichTextBox Methods 106

Using WPF Commands 108

Try It 110

Lesson Requirements 110

Hints 110

Step-by-Step 110

Exercises 112

LESSON 8: USING STANDARD DIALOGS 115

Using Dialogs in General 116

Adding the Dialog to the Form 117

Initializing the Dialog 117

Displaying the Dialog and Checking the Return Result 118

Processing the Results 119

Putting It All Together 120

Using Dialog Properties 120

Using File Filters 123

Using Dialogs in WPF 124

Try It 126

Lesson Requirements 126

Hints 127

Step-by-Step 127

Exercises 130

LESSON 9: CREATING AND DISPLAYING NEW FORMS 133

Adding New Forms 133

Understanding Classes and Instances 134

Displaying Forms 135

Controlling Remote Forms 138

Try It 140

Lesson Requirements 141

Hints 141

Step-by-Step 141

Exercises 143

LESSON 10: BUILDING CUSTOM DIALOGS 147

Making Custom Dialogs 147

Setting the Dialog Result 148

Using Custom Dialogs 149

Try It 150

Lesson Requirements 150

Hints 151

Step-by-Step 151

Exercises 153

PART II: VARIABLES AND CALCULATIONS

LESSON 11: USING VARIABLES AND PERFORMING CALCULATIONS 161

What Are Variables? 161

Data Types 161

Float, Double, and Decimal Data Types 163

Declaring Variables 164

Literal Values 165

Type Conversions 167

Casting 168

Converting 169

Parsing 169

Performing Calculations 170

Operands and Operators 171

Promotion 171

Operator Summary 171

Precedence 177

Constants 179

Try It 179

Lesson Requirements 180

Hints 180

Step-by-Step 181

Exercises 182

LESSON 12: DEBUGGING CODE 187

Deferred Techniques 187

Debugging Then and Now 188

Setting Breakpoints 188

Reading Variables 189

Stepping through Code 190

Using Watches 191

Using the Immediate Window 192

Try It 193

Lesson Requirements 193

Step-by-Step 194

Exercises 196

LESSON 13: UNDERSTANDING SCOPE 199

Scope within a Class 199

Same Named Variables 200

Method Variable Lifetime 201

Block Scope 202

Accessibility 203

Restricting Scope and Accessibility 204

Try It 204

Lesson Requirements 205

Hints 205

Step-by-Step 205

Exercises 208

LESSON 14: WORKING WITH STRINGS 211

String Methods 211

Format and ToString 213

Standard Numeric Formats 215

Custom Numeric Formats 217

Standard Date and Time Formats 218

Custom Date and Time Formats 219

Try It 222

Lesson Requirements 222

Hints 222

Step-by-Step 222

Exercises 223

LESSON 15: WORKING WITH DATES AND TIMES 225

Creating DateTime Variables 225

Local and UTC Time 226

DateTime Properties and Methods 226

TimeSpans 228

Try It 229

Lesson Requirements 230

Hints 230

Step-by-Step 230

Exercises 231

LESSON 16: USING ARRAYS AND COLLECTIONS 233

Arrays 233

Creating Arrays 234

A Fibonacci Example 235

Multi-Dimensional Arrays 236

Array Properties and Methods 237

Collection Classes 238

Generic Classes 239

Lists 240

SortedLists 240

Dictionaries 242

Queues 242

Stacks 242

Try It 243

Lesson Requirements 243

Step-by-Step 244

Exercises 245

LESSON 17: USING ENUMERATIONS AND STRUCTURES 249

Enumerations 249

Structures 250

Structures versus Classes 251

Reference Types 251

Value Types 252

Other Differences 252

Where to Put Structures 254

Try It 254

Lesson Requirements 255

Step-by-Step 255

Exercises 257

PART III: PROGRAM STATEMENTS

LESSON 18: MAKING CHOICES 263

Decision Statements 263

if Statements 264

if-else Statements 265

Cascading if Statements 265

Nested if Statements 266

switch Statements 267

Try It 269

Lesson Requirements 269

Hints 269

Step-by-Step 269

Exercises 270

LESSON 19: REPEATING PROGRAM STEPS 275

for Loops 275

foreach Loops 277

while Loops 278

do Loops 279

break and continue 281

Try It 282

Lesson Requirements 282

Hints 282

Step-by-Step 283

Exercises 284

LESSON 20: REUSING CODE WITH METHODS 289

Method Advantages 290

Method Syntax 291

Using ref Parameters 294

Using out Parameters 295

Try It 296

Lesson Requirements 296

Hints 296

Step-by-Step 296

Exercises 298

LESSON 21: HANDLING ERRORS 301

Errors and Exceptions 301

try-catch Blocks 302

TryParse 304

Throwing Exceptions 305

Try It 307

Lesson Requirements 307

Hints 308

Step-by-Step 308

Exercises 309

LESSON 22: PREVENTING BUGS 313

Input Assertions 313

Other Assertions 316

Try It 316

Lesson Requirements 317

Hints 317

Step-by-Step 317

Exercises 319

PART IV: CLASSES

LESSON 23: DEFINING CLASSES 325

What Is a Class? 325

Class Benefi ts 326

Making a Class 327

Properties 327

Try It 330

Lesson Requirements 330

Step-by-Step 330

Methods 331

Events 332

Delegates 332

Event Handler Delegates 333

Try It 336

Lesson Requirements 336

Hints 337

Step-by-Step 337

Inheritance 339

Polymorphism 340

Try It 341

Lesson Requirements 341

Hints 341

Step-by-Step 342

Exercises 344

LESSON 24: INITIALIZING OBJECTS 347

Initializing Objects 347

Constructors 348

Parameterless Constructors 349

Parameterized Constructors 349

Destructors 350

Invoking Other Constructors 352

Try It 354

Lesson Requirements 354

Hints 355

Step-by-Step 355

Exercises 358

LESSON 25: FINE-TUNING CLASSES 361

Overloading Methods 361

Overriding Methods 362

Overriding ToString 363

Try It 365

Lesson Requirements 365

Hints 365

Step-by-Step 366

Exercises 367

LESSON 26: OVERLOADING OPERATORS 371

Overloadable Operators 371

Unary Operators 372

Binary Operators 373

Comparison Operators 374

Conversion Operators 374

Try It 375

Lesson Requirements 375

Hints 376

Step-by-Step 376

Exercises 379

LESSON 27: USING INTERFACES 383

Interface Advantages 383

Multiple Inheritance 383

Code Generalization 384

Implementing Interfaces 385

Defining Interfaces 388

Try It 389

Lesson Requirements 389

Hints 390

Step-by-Step 390

Exercises 392

LESSON 28: MAKING GENERIC CLASSES 397

Defining Generic Classes 397

Using Generic Constraints 399

Making Generic Methods 400

Try It 401

Lesson Requirements 401

Hints 402

Step-by-Step 402

Exercises 403

PART V: SYSTEM INTERACTIONS

LESSON 29: USING FILES 409

Filesystem Classes 409

DriveInfo 410

DirectoryInfo 410

Directory 412

FileInfo 412

File 413

Path 414

Streams 415

Writing Files 416

Reading Files 417

Try It 418

Lesson Requirements 418

Hints 418

Step-by-Step 418

Exercises 419

LESSON 30: PRINTING 421

Windows Forms Printing 421

Getting Started 422

Starting a Printout 422

Drawing Shapes 423

Drawing Text 424

WPF Printing 425

Printing Visuals 426

Try It 431

Lesson Requirements 431

Hints 431

Step-by-Step 432

Exercises 434

PART VI: WINDOWS APPS

LESSON 31: WINDOWS STORE APPS 439

Navigation Style 439

App Styles 440

App Images 440

Deployment 444

Deploying Locally 444

Deploying to the Windows Store 445

WPF Techniques 446

Using Styles 446

Setting Dependency Properties 447

Try It 448

Lesson Requirements 448

Hints 449

Step-by-Step 449

Exercises 452

LESSON 32: WINDOWS PHONE APPS 455

Building Apps 455

Navigation Style 458

App Styles 458

App Images 459

Try It 461

Lesson Requirements 461

Step-by-Step 462

Exercises 462

PART VII: SPECIALIZED TOPICS

LESSON 33: LOCALIZING PROGRAMS 467

Understanding Localization 468

Building Localized Interfaces 469

Testing Localizations 469

Processing Locale-Specific Values 470

Try It 472

Lesson Requirements 472

Hints 472

Step-by-Step 472

Exercises 474

LESSON 34: PROGRAMMING DATABASES, PART 1 479

Connecting to a Database 479

Displaying Data in a Grid 483

Displaying Data One Record at a Time 486

Try It 488

Lesson Requirements 488

Hints 488

Step-by-Step 488

Exercises 489

LESSON 35: PROGRAMMING DATABASES, PART 2 493

Searching 493

Filtering 494

Sorting 495

Try It 495

Lesson Requirements 495

Hints 496

Step-by-Step 496

Exercises 496

LESSON 36: LINQ TO OBJECTS 499

LINQ Basics 499

where Clauses 501

order by Clauses 504

select Clauses 504

Try It 507

Lesson Requirements 508

Hints 508

Step-by-Step 508

Exercises 509

LESSON 37: LINQ TO SQL 511

Connecting to the Database 511

Making LINQ to SQL Classes 515

Writing Code 517

Using LINQ Queries 518

Understanding Nullable Fields 519

Understanding Query Execution 520

Using LINQ to SQL with Access 522

Try It 524

Lesson Requirements 524

Hints 524

Step-by-Step 524

Exercises 525

AFTERWORD: WHAT’S NEXT? 527

INDEX 529

Rights Sold

loading