38,99 €
A perfectly crafted prep guide that prepares you for the MCSD 70-483 The MCSD 70-483 exam is the entry-level Microsoft certification exam for C# developers and this must-have resource offers essential coverage of the exam that will test your competency in C# programming. Each chapter covers one of the core subject domains that comprise the exam. Among the authors are experienced trainers who advised Microsoft on the development of its certification programs, affording them a unique understanding of both the objectives and what it takes to master them. This invaluable knowledge is passed to you so that you will not only be prepared to take the exam, but also become a better C# developer * Features a step-by-step lab tutorial for each lesson covered in the book, encouraging you to practice what you've just learned in order to reinforce your learning * Includes an accompanying website that includes more than 100 simulated test questions and answers * Shares solutions to the hands-on labs presented in the book * Contains complete sample code * Offers a unique author approach that not only teaches you how to answer a set of exam questions but also provides you with an understanding of the underlying concepts and skills needed to succeed as a professional C# programmer MCSD Certification Toolkit is all you need to fully prepare for exam 70-483!
Sie lesen das E-Book in den Legimi-Apps auf:
Seitenzahl: 928
Veröffentlichungsjahr: 2013
Cover
Title
Copyright
Dedication
About the Authors
About the Technical Editor
Credits
Acknowledgments
Introduction
Who This Book Is For
What This Book Covers
How This Book Is Structured
What You Need to Use This Book
Conventions
Study Material and Code on the Website
Errata
p2p.wrox.com
Chapter 1: Introducing the Programming C# Certification
Getting Certified
Things to Know About the Test
How to Study for the Exam Using This Book
The 70-483 Objectives
Summary
Additional Reading and Resources
Chapter 2: Basic Program Structure
Writing Your First Program
Controlling Program Flow
Summary
Test Questions
Additional Reading and Resources
Cheat Sheet
Review of Key Terms
Chapter 3: Working with the Type System
Creating Value Types
Creating Reference Types
Understanding Encapsulation
Understanding Generic Types and Generic Methods
Summary
Chapter Test Questions
Additional Reading and Resources
Cheat Sheet
Review of Key Terms
Chapter 4: Using Types
Converting Between Types
Manipulating Strings
Formatting Values
Summary
Test Questions
Additional Reading and Resources
Cheat Sheet
Review of Key Terms
Chapter 5: Creating and Implementing Class Hierarchies
Inheriting from a Base Class
Designing and Implementing Interfaces
Implementing Common Interfaces
Managing Object Life Cycle
Summary
Test Questions
Additional Reading and Resources
Cheat Sheet
Review of Key Terms
Chapter 6: Working with Delegates, Events, and Exceptions
Working with Delegates
Working with Events
Exception Handling
Summary
Chapter Test Questions
Additional Reading and Resources
Cheat Sheet
Review of Key Terms
Chapter 7: Multithreading and Asynchronous Processing
Creating Responsive Applications
Working with the Task Parallel Library
Exploring Advanced Multithreading Programming Topics
Summary
Chapter Test Questions
Additional Reading and Resources
Cheat Sheet
Review of Key Terms
Chapter 8: Creating and Using Types with Reflection, Custom Attributes, the CodeDOM, and Lambda Expressions
Using the System.Reflection Namespace
Read and Create Custom Attributes
Generate Code Using the CodeDOM Namespace
Lambda Expressions
Summary
Chapter Test Questions
Additional Reading and Resources
Cheat Sheet
Review of Key Terms
Chapter 9: Working with Data
Working with Data Collections
Consuming Data
Performing I/O Operations
Understanding Serialization
Summary
Chapter Test Questions
Additional Reading and Resources
Cheat Sheet
Review of Key Terms
Chapter 10: Working with Language Integrated Query (LINQ)
Understanding Query Expressions
Summary
Chapter Test Questions
Additional Reading and Resources
Review of Key Terms
Chapter 11: Input Validation, Debugging, and Instrumentation
Input Validation
Debugging
Instrumenting Applications
Summary
Chapter Test Questions
Additional Reading and Resources
Cheat Sheet
Review of Key Terms
Chapter 12: Using Encryption and Managing Assemblies
Using Encryption
Managing Assemblies
Summary
Chapter Test Questions
Additional Reading and Resources
Cheat Sheet
Review of Key Terms
Appendix: Answers to Sample Test Questions
Chapter 1: Introducing the Programming in C# Certification
Chapter 2: Basic Program Structure
Chapter 3: Working with the Type System
Chapter 4: Using Types
Chapter 5: Creating and Implementing Class Hierarchies
Chapter 6: Working with Delegates, Events, and Exceptions
Chapter 7: Multithreading and Asynchronous Processing
Chapter 8: Creating and Using Types with Reflection, Custom Attributes, the CodeDOM, and Lambda Expressions
Chapter 9: Working with Data
Chapter 10: Working with Language Integrated Query (LINQ)
Chapter 11: Input Validation, Debugging, and Instrumentation
Chapter 12: Using Encryption and Managing Assemblies
Advertisements
Wiley End User License Agreement
Cover
Table of Contents
Begin Reading
Chapter 2: Basic Program Structure
Table 2-1: 70-483 Exam Objectives Covered in This Chapter
Table 2-2: Relational Operators
Table 2-3: Boolean (Boolean and Bitwise) Operators
Chapter 3: Working with the Type System
Table 3-1: 70-483 Exam Objectives Covered in This Chapter
Table 3-2: C# Data Types
Chapter 4: Using Types
Table 4-1: 70-483 Exam Objectives Covered in This Chapter
Table 4-2: Data Types That Provide Parse and TryParse Methods
Table 4-3: NumberStyles Enumeration Values
Table 4-4: Basic System.Convert Data Conversion Methods
Table 4-5: Useful Static String Methods
Table 4-6: Useful String Instance Methods
Table 4-7: Useful StringBuilder Properties
Table 4-8: Useful StringBuilder Methods
Table 4-9: Useful StringWriter Methods
Table 4-10: Useful StringReader Methods
Table 4-11: Standard Numeric Format Strings
Table 4-12: Standard DateTime Format Strings
Chapter 5: Creating and Implementing Class Hierarchies
Table 5-1: 70-483 Exam Objectives Covered in This Chapter
Chapter 6: Working with Delegates, Events, and Exceptions
Table 6-1: 70-483 Exam Objectives Covered in This Chapter
Table 6-2: Useful Exception Classes
Table 6-3: Useful SqlException Properties
Table 6-4: Floating Point Special Value Methods
Table 6-5: Exception Class Properties
Chapter 7: Multithreading and Asynchronous Processing
Table 7-1: 70-483 Exam Objectives Covered in This Chapter
Table 7-2: System.Threading.ThreadPool Methods
Table 7-3: System.ComponentModel.BackgroundWorker Methods
Table 7-4: System.ComponentModel.BackgroundWorker Properties
Table 7-5: System.ComponentModel.BackgroundWorker Events
Table 7-6: System.Threading.Tasks.Task Methods
Table 7-7: System.Threading.Tasks.Task Properties
Table 7-8: System.Threading.Tasks.TaskFactory Methods
Table 7-9: System.Threading.Tasks.TaskCreationOptions Members
Table 7-10: System.Threading.Tasks.Parallel Methods
Table 7-11: System.Threading.EventWaitHandle Methods
Table 7-12: System.Threading.CountdownEvent Methods
Table 7-13: System.Threading.CountdownEvent Properties
Table 7-14: System.Threading.Barrier Methods
Table 7-15: System.Threading.Barrier Properties
Table 7-16: System.Threading.Monitor Methods
Table 7-17: System.Threading.Interlocked Methods
Table 7-18: System.Collections.Concurrent.IProducerConsumerCollection Interface
Table 7-19: System.Collections.Concurrent Classes
Chapter 8: Creating and Using Types with Reflection, Custom Attributes, the CodeDOM, and Lambda Expressions
Table 8-1: 70-483 Exam Objectives Covered in This Chapter
Table 8-2: Commonly Used Classes in the System.Reflection Namespace
Table 8-3: Commonly Used System.Reflection.Assembly Properties
Table 8-4: Commonly Used System.Reflection.Assembly Methods
Table 8-5: Commonly Used Properties of the System.Type Class
Table 8-6: Commonly Used Methods of the System.Type Class
Table 8-7: Commonly Used Classes in the CodeDOM Namespace
Chapter 9: Working with Data
Table 9-1: 70-483 Exam Objectives Covered in This Chapter
Table 9-2: System.Collections
Table 9-3: Common System.Array Properties
Table 9-4: Common System.Array Methods
Table 9-5: System.Collections.Generic
Table 9-6: Common System.Collections.Generic.Dictionary Methods
Table 9-7: System.Collections.CollectionBase Properties
Table 9-8: System.Collections.CollectionBase Methods (Partial List)
Table 9-9: Common System.Data.Common.DBConnection Properties
Table 9-10: System.Data.Common.DBConnection Methods (Partial List)
Table 9-11: Commonly used Properties for System.Data.Common.DBDataReader
Table 9-12: Commonly used method for the System.Data.Common.DBDataReader
Table 9-13: OData Query Options
Table 9-14: OData $filter Query Options
Table 9-15: OData $filter string Functions
Table 9-16: OData $filter date Functions
Table 9-17: OData $filter math Functions
Table 9-18: OData $filter type Functions
Table 9-19: File and Directory Classes
Table 9-20: FileInfo Properties
Table 9-21: File and FileInfo Methods
Table 9-22: DirectoryInfo Properties
Table 9-23: Directory and DirectoryInfo Methods
Table 9-24: Streams
Table 9-25: FileMode Enumeration
Table 9-26: FileAccess Enumeration
Table 9-27: FileShare Enumeration
Table 9-28: FileIOPermissionAccess Enumeration
Table 9-29: Reader and Writer Classes (Partial List)
Table 9-30: StreamReader Methods (Partial List)
Chapter 10: Working with Language Integrated Query (LINQ)
Table 10-1: 70-483 Exam Objectives Covered in This Chapter
Chapter 11: Input Validation, Debugging, and Instrumentation
Table 11-1: 70-483 Exam Objectives Covered in This Chapter
Table 11-2: Useful String Validation Methods
Table 11-3: Useful Regex Methods
Table 11-4: Useful Character Escapes
Table 11-5: Useful Character Class Constructs
Table 11-6: Useful Anchors
Table 11-7: Regular Expression Options
Table 11-8: Quantifiers
Table 11-9: Useful Debug and Trace Methods
Table 11-10: Useful Regular Expression Components
Chapter 12: Using Encryption and Managing Assemblies
Table 12-1: 70-483 Exam Objectives Covered in This Chapter
Table 12-2: Symmetric Algorithms Implemented in .NET
Table 12-3: System.Security.Cryptography.SymmetricAlgorithm Properties
Table 12-4: System.Security.Cryptography.SymmetricAlgorithm Methods
Table 12-5: Asymmetric Algorithms Implemented in .NET
Table 12-6: Hash Algorithms Implemented in .NET
Table 12-7: System.Security.Cryptography.HashAlgorithm Properties
Table 12-8: System.Security.Cryptography.HashAlgorithm Methods
Table 12-9: System.Security.Cryptography.KeyedHashAlgorithm Properties
Table 12-10: System.Security.Cryptography.X509Certificates.StoreLocation
Table 12-11: System.Security.Cryptography.X509Certificates.StoreName
Table 12-12: System.Reflection.ProcessorArchitecture Members
Table 12-13: gacutil.exe Usage
Chapter 2: Basic Program Structure
Figure 2-1: Output of code lab
Figure 2-2: Counter Initialization
Figure 2-3: Counter prior to increment portion of loop
Figure 2-4: Counter has incremented.
Figure 2-5: Output of while loop
Figure 2-6: do-while execution
Figure 2-7: do-while after setting variable to 10
Figure 2-8: Using a sentinel to end a loop
Chapter 3: Working with the Type System
Figure 3-1: IntelliSense displaying enumeration list
Figure 3-2: Output of value_type_passing
Figure 3-3: Built-in methods
Figure 3-4: Extension method added
Figure 3-5: IntelliSense displaying the properties
Chapter 4: Using Types
Figure 4-1: Use the Advanced Build Settings dialog to make the program check for integer overflow and underflow.
Figure 4-2: When you cast an array of reference values, the new variable still refers to the original array.
Figure 4-3: This order entry form parses numeric and currency values entered by the user.
Figure 4-4: The permutations example program displays the permutations of a set of letters.
Figure 4-5: This program uses StringBuilders to list initial sequences of the alphabet.
Chapter 5: Creating and Implementing Class Hierarchies
Figure 5-1: The ThisAndBase example program demonstrates constructors that invoke other constructors.
Figure 5-2: By deriving classes from each other, you can build class hierarchies.
Figure 5-3: C# does not enable a class such as TeachingAssistant to inherit from more than one parent class.
Figure 5-4: The IComparableCars example program displays a list of Car objects sorted on the left and unsorted on the right.
Figure 5-5: The IComparerCars example program displays a list of Car objects sorted by Name, MaxMph, Horsepower, or Price.
Figure 5-6: The IEnumerableTree example program enumerates over the nodes in a tree.
Chapter 6: Working with Delegates, Events, and Exceptions
Figure 6-1: The GraphFunction example program uses a delegate variable to store the function that it should graph.
Figure 6-2: The StaticAndInstanceDelegates example program demonstrates delegates set to static and instance methods.
Figure 6-3: Lambda expressions can take any number of parameters.
Figure 6-4: The equation for the GraphFunction program’s third function shown here is easier to read in a statement lambda than in an expression lambda.
Figure 6-5: An OverdraftAccount object can remove money from its associated SavingsAccount object if necessary.
Figure 6-6: Visual Studio’s code editor can insert the default event handler name for you.
Figure 6-7: Visual Studio’s code editor can generate an event handler for you.
Figure 6-8: Visual Studio’s Properties window enables you to select or create event handlers.
Figure 6-9: The form designer won’t display a form if a subscribed event handler is missing.
Figure 6-10: Delete the line that subscribes the missing event handler to fix the form.
Figure 6-11: If a program running inside Visual Studio encounters an unhandled exception, execution stops at the statement that threw the exception and this message box appears.
Figure 6-12: If a program running outside of Visual Studio encounters an unhandled exception, this message box appears.
Figure 6-13: All of the exception classes in this hierarchy are descendants of the System.Exception class.
Chapter 7: Multithreading and Asynchronous Processing
Figure 7-1: Single-threaded compute-intensive application
Figure 7-2: Multithreaded compute-intensive application
Chapter 8: Creating and Using Types with Reflection, Custom Attributes, the CodeDOM, and Lambda Expressions
Figure 8-1: Table design in SQL Server Enterprise Manager
Chapter 9: Working with Data
Figure 9-1: Two-dimensional array
Figure 9-2: Northwinds Model - Entity Framework Designer
Figure 9-3: Add Service Reference dialog
Chapter 11: Input Validation, Debugging, and Instrumentation
Figure 11-1: A new order form contains many validations.
Figure 11-2: If an assertion fails, the Debug.Assert method displays a dialog that includes a stack trace showing where the assertion failed.
Figure 11-3: You can use regions to hide blocks of code to make a file easier to read.
Figure 11-4: The Output window displays information about warnings including their numbers.
Figure 11-5: Use the Configuration Manager to select a debug or release build.
Figure 11-6: You can use the project’s Build property page to define conditional compilation constants.
Figure 11-7: The WriteToEventLog program writes messages into the system event logs.
Figure 11-8: The system’s Event Viewer displays log entries.
Figure 11-9: The Performance Wizard lets you study an application’s memory of CPU usage.
Figure 11-10: The profiler’s output lets you see the most active call path, the methods sampled most often, and other statistics.
Figure 11-11: You can use Visual Studio’s Sever Explorer to create new performance counters.
Figure 11-12: The Performance Monitor lets you view performance counters graphically.
Chapter 12: Using Encryption and Managing Assemblies
Figure 12-1: Output of string hashing
Figure 12-2: The root certificate authorities list
Figure 12-3: SSL certificate info for Microsoft.com
Figure 12-4: Assembly Information dialog
Figure 12-5: Opening the AssemblyInfo.cs file
Figure 12-6: File and product version information
Figure 12-7: The Signing tab in Visual Studio 2012
Figure 12-8: Create Strong Name Key dialog
Figure 12-9: Sn.exe output
Figure 12-10: Invoking ildasm.exe
Figure 12-11: The IL DASM main application window
Figure 12-12: The IL DASM MANIFEST window
Figure 12-13: Output from set PATH command
Figure 12-14: The GAC view from Windows Explorer
cover
contents
v
vi
vii
ix
x
xi
xiii
xv
xxvii
xxviii
xxix
xxx
xxxi
xxxii
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
Tiberiu Covaci
Gerry O’Brien
Rod Stephens
Vince Varallo
MCSD Certification Toolkit (Exam 70-483): Programming in C#
Published by John Wiley & Sons, Inc. 10475 Crosspoint Boulevard Indianapolis, IN 46256www.wiley.com
Copyright © 2013 by John Wiley & Sons, Inc., Indianapolis, Indiana
Published simultaneously in Canada
ISBN: 9781118612095
ISBN: 978-1-118-61206-4 (ebk)
ISBN: 978-1-118-72950-2 (ebk)
ISBN: 978-1-118-72929-8 (ebk)
Manufactured in the United States of America
10 9 8 7 6 5 4 3 2 1
No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permission should be addressed to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-6011, fax (201) 748-6008, or online at http://www.wiley.com/go/permissions.
Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations or warranties with respect to the accuracy or completeness of the contents of this work and specifically disclaim all warranties, including without limitation warranties of fitness for a particular purpose. No warranty may be created or extended by sales or promotional materials. The advice and strategies contained herein may not be suitable for every situation. This work is sold with the understanding that the publisher is not engaged in rendering legal, accounting, or other professional services. If professional assistance is required, the services of a competent professional person should be sought. Neither the publisher nor the author shall be liable for damages arising herefrom. The fact that an organization or Web site is referred to in this work as a citation and/or a potential source of further information does not mean that the author or the publisher endorses the information the organization or Web site may provide or recommendations it may make. Further, readers should be aware that Internet Web sites listed in this work may have changed or disappeared between when this work was written and when it is read.
For general information on our other products and services please contact our Customer Care Department within the United States at (877) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002.
Wiley publishes in a variety of print and electronic formats and by print-on-demand. Some material included with standard print versions of this book may not be included in e-books or in print-on-demand. If this book refers to media such as a CD or DVD that is not included in the version you purchased, you may download this material at http://booksupport.wiley.com. For more information about Wiley products, visit www.wiley.com.
Library of Congress Control Number: 2013933931
Trademarks: Wiley, the Wiley logo, Wrox, the Wrox logo, Programmer to Programmer, and related trade dress are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates, in the United States and other countries, and may not be used without written permission. All other trademarks are the property of their respective owners. John Wiley & Sons, Inc., is not associated with any product or vendor mentioned in this book.
To Lia for her patience and understanding during the writing process. All my love.
—Gerry O’Brien
For Maki.
—Rod Stephens
To Renee, Madison, and Courtney.
—Vince Varallo
Tiberiu Covaci is an Independent trainer and mentor teaching C# and .NET in general, and ASP.NET and parallel computing in particular. He works closely with Microsoft Learning helping them develop new courses, conducting beta classes and doing technology reviews for the upcoming courses. He was part of the Microsoft Certified Trainer Advisory Council between 2010 and 2012.
Tiberiu is a popular speaker at industry conferences and user groups around the world. His sessions and workshops get good reviews from both the attendees and the organizers.
Tiberiu is a Microsoft Certified Trainer and holds almost all .NET certification from .NET 2.0 and forward. He is as well an IASA certified trainer, an ASP.NET Insider, and a Telerik Insider. He is an INETA Speaker Bureau member and IASA Speaker. For his dedication and passion, Microsoft and Telerik presented Tibi with the MVP Award.
Tiberiu is the husband of lovely Nicoleta and the proud father of Anna and Disa.
Gerry O’Brien currently works at Microsoft as a program manager in Microsoft Learning where he manages internal tools and platforms working with teams of developers and testers. Prior to the program manager role, Gerry worked as the Certification Product Planner for the developer and SQL Server audiences at Microsoft Learning. In that role, he planned the exam portfolio for these audiences, working with industry experts to define the exam content and manage the exam from envisioning through development, beta, and release. Prior to working at Microsoft, Gerry worked as a software development consultant and trainer.
Rod Stephens started out as a mathematician, but, while studying at MIT, discovered how much fun programming is and has been programming professionally ever since. During his career, he has worked on an eclectic assortment of applications in such fields as telephone switching, billing, repair dispatching, tax processing, wastewater treatment, concert ticket sales, cartography, and training for professional football players.
Rod is a Microsoft Visual Basic Most Valuable Professional (MVP) and has taught introductory programming at ITT Technical Institute. He has written more than two dozen books that have been translated into languages from all over the world, and more than 250 magazine articles covering Visual Basic, C#, Visual Basic for Applications, Delphi, and Java.
Rod’s popular VB Helper website (www.vb-helper.com) receives several million hits per month and contains thousands of pages of tips, tricks, and example programs for Visual Basic programmers, as well as example code for this book. His C# Helper website (www.csharphelper.com) contains similar material for C# programmers.
You can contact Rod at [email protected] or [email protected].
Vince Varallo has been developing applications using Microsoft technologies for the past 17 years. He began his career as a Visual Basic 3 developer and has worked with VB 4, 5, and 6 until the .NET Framework 1.0 was released. He was an early adopter of ASP.NET and C#, and has concentrated on line-of-business applications throughout his entire career. He is currently the director of Technology Solutions at a digital marketing agency where he works with a wide variety of technologies. He previously authored ASP.NET 3.5 Enterprise Application Development with Visual Studio 2008 and contributed ace Varallo has been developins an author for Professional Visual Basic 6: The 2003 Programmer’s Resource.
Anders Bratland combines his two passions, programming and teaching other people how to program, by working as a freelance consultant, which gives him the chance to work both as a Microsoft Certified Trainer and as a developer.
Anders is a well-known speaker at conferences like TechDays, Scandinavian Developer Conference, and Developer Summit. Anders is also active as speaker in different user groups, such as DotnetForum, and also as one of the organizers in the largest Swedish user group, Swenug.
Anders has a strong commitment to techniques and methods that can help projects to be successful, especially by adopting agile values and disciplines.
Anders is a Microsoft ASP.NET MVP and a member of the Swedish Microsoft Extended Expert Team, MEET.
Executive Editor: Robert Elliott
Project Editor: Jennifer Lynn
Technical Editor: Anders Bratland
Production Editor: Daniel Scribner
Copy Editor: San Dee Phillips
Editorial Manager: Mary Beth Wakefield
Freelancer Editorial Manager: Rosemarie Graham
Associate Director of Marketing: David Mayhew
Marketing Manager: Ashley Zurcher
Business Manager: Amy Knies
Production Manager: Tim Tate
Vice President and Executive Group Publishe: rRichard Swadley
Vice President and Executive Publisher: Neil Edde
Associate Publisher: Jim Minatel
Project Coordinator, Cover: Katie Crocker
Compositor: Jeff Lytle, Happenstance Type-O-Rama
Proofreader: James Saturnio, Word One
Indexer: Ron Strauss
Cover Designer: Wiley
Cover Image: iStockphoto/microstocker
I would like to thank my lovely wife Nicoleta and my daughters, Anna and Disa, for supporting me and putting up with me for the past three years. I know this was a long process, and I know you might have not liked it at times, but now that is done I hope that people will find it educational and then all of it was worth it.
I want to thank Bob Elliott for believing in me even when I didn’t. I want to thank Jennifer Lynn and Rosemarie Graham for their help in making this book happen. I would like to thank Anders Bratland for lending his expertise and making sure that this book is technologically accurate. I would like to thank my co-authors Gerry O’Brien, Rod Stephens, and Vince Varallo for their hard work and devotion.
I would also like to thank Sergiu Damian for his help reviewing my chapters, Catalin Pop for helping me with his expertise on encryption, and Susan Ibach and Christopher Harrison for recommending me as author.
Last but not least I would like to thank my parents for making me who I am.
—Tiberiu Covaci
When we first talked about writing this book, our idea was to offer a way to our readers to learn to program using C#, and the byproduct of this process was for you to pass the 70-483 certification exam given by Microsoft. Being certified on specific technologies helps you in many ways. First, it helps you understand which parts are considered by the specialists to be important. Second, it helps you to understand a new technology by having a goal. Finally, it helps you in your career because certifications are recognized by employers, and this can give you advantage over other applicants.
Microsoft recommends that you have at least 1 year of experience programming in C# before attempting to take Exam 70-483. In addition, we recommend that you have some experience with other programming languages, although it is not necessary. If you are an experienced programmer, we recommend you to skim the chapters you are familiar with and read in detail those chapters you are not so confident about. If you are a novice programmer, we recommend you read the entire book, and make sure you understand all the chapter test questions and the study the Cheat Sheet at the end of every chapter.
This book covers C# language version 5.0 and .NET Framework version 4.5. We tried to cover all the skills measured by Exam 70-483, with each chapter focusing on specific key objectives. We provide, as well, many representative sample test questions that are similar to the ones used by Microsoft. You can find these questions at the end of every chapter.
Instead of following the test objectives as they were specified by Microsoft, this book follows a more natural approach to learning, where the knowledge base is built gradually.
In every chapter in this book you can find the following parts:
A table showing how each chapter correlates to the test objectives
Real-world case scenarios and code labs with solutions
Advice, warnings, best practices, common mistakes, notes, and sidebars to point out important material
Chapter test questions structured similar to how you will see questions on the exam
Additional reading and resources
Cheat Sheets
Review of key terms
NOTE The chapter test questions and answers, the Cheat Sheet, and Review of Key Terms are also available on the website for you to download and print.
Following is a breakdown of each chapter’s focuses:
Chapter 1, “Introducing the Programming C# Certification Test”: This chapter introduces you to the Microsoft certification process and to the specifics of the 70-483 Programming in C# certification.
Chapter 2, “Basic Program Structure”: This chapter covers the topics necessary for you to be successful in understanding core functionality in the C# programming language. Key topics enable you to learn about statements in C#, both simple and complex. At the end of this chapter, you will understand how to create basic programs in C#.
Chapter 3, “Working with the Type System”: This chapter covers the type system in C#. You learn about value and reference types, how to define them, and how to use them. You also learn the basic concepts of object-oriented programming.
Chapter 4, “Using Types”: This chapter talks about how to work with types, convert between data types, and work with dynamic types. After that you explore different ways to work with strings.
Chapter 5, “Creating and Implementing Class Hierarchies”: This chapter continues the discussion about object-oriented programming (started in Chapter 3), and describes how to create class hierarchies and classes that implement common .NET interfaces. It also covers the object’s life cycle and how to handle unmanaged resources.
Chapter 6, “Working with Delegates, Events, and Exceptions”: This chapter continues the discussion started in Chapter 3 about the type system and talks about two special data types: exceptions and delegates. After that, it discusses how to work with delegates to create and use events.
Chapter 7, “Multithreading and Asynchronous Processing”: This chapter shows you how to improve the performance of your application by using threads, tasks, and the new asynchronous programming paradigm introduced in C# 5.0.
Chapter 8, “Creating and Using Types with Reflection, Custom Attributes, the CodeDOM, and Lambda Expressions”: Reflection is the capability to analyze code dynamically, read, modify, and even invoke behavior dynamically. You learn how to define metadata for your code by using Attribute classes. You also learn how to create code generators using the CodeDOM. Finally, you learn how to query sets of data using expression- and method-based lambda expressions.
Chapter 9, “Working with Data”: This chapter looks at different ways to work with data sets. It discusses arrays, collections, and technologies such as ADO.NET, ADO.NET Entity Framework, and WCF Data Services and how to work with the I/O system.
Chapter 10, “Working with Language Integrated Query (LINQ)”: This chapter covers ways to query data by using the Language Integrated Query.
Chapter 11, “Input Validation, Debugging, and Instrumentation”: This chapter starts by talking about different ways to validate data input. After that it continues to talk about ways to debug and instrument applications to minimize the errors.
Chapter 12, “Using Encryption and Managing Assemblies”: This chapter covers two apparently unrelated technologies. First, you cover encryption to understand how to ensure data integrity and privacy. After that you cover ways to manage assemblies as deployment units.
To run the samples in the book, you need the following:
A computer running Windows 7 or above
Visual Studio 2012 Professional Edition or above. If you don’t have this version, you can download a 90-day trial version from Microsoft (see
http://www.microsoft.com/visualstudio/eng/downloads
).
The source code for the samples is available for download from the Wrox website at www.wrox.com/remtitle.cgi?isbn=1118612094.
To help you get the most from the text and keep track of what's happening, we’ve used a number of conventions throughout the book.
The Real-World Case Scenario is an exercise similar to what may appear on the test. You should work through problems, following the text in the book.
Solution
After each Real-World Case Scenario, the example is explained in detail.
The Code Lab focuses on code highlights discussed earlier. You must understand how and why this code is used for the purpose shown to pass the test.
Solution
After each Code Lab, the code and what it does is explained in detail.
These boxes highlight mistakes you have made or seen others make. Here, you get a chance to learn from others’ hard-learned lessons.
You are reading this book primarily to pass the MCSD Certification test. This feature covers topics highlighted because they are important for the test but also for common work practices.
In these boxes you can find advice from the authors. We’ve been there before, and we want you to learn from what we’ve learned.
Here, you can find information that focuses on the Microsoft certification test or test-taking skills in general.
WARNING Warnings hold important, not-to-be-forgotten information directly relevant to the surrounding text.
NOTE Notes point out important facts for you to remember.
As for styles in the text:
We
highlight
new terms and important words when we introduce them.
We show keyboard strokes like this: Ctrl+A.
We show filenames, URLs, and code within the text like so:
persistence.properties
We present code in two different ways:
We use a monofont type with no highlighting for most code examples.
We use bold to emphasize code that is particularly important in the present
context or to show changes from a previous code snippet.
As you work through the examples in this book, you may choose either to type in all the code manually or to use the source code files that accompany the book. All the source code used in this book is available for download at www.wrox.com. Specifically for this book, the code download is on the Download Code tab at www.wrox.com/remtitle.cgi?isbn=1118612094.
You can also search for the book at www.wrox.com to find the code. Alternatively, you can go to the main Wrox code download page at www.wrox.com/dynamic/books/download.aspx to see the code available for this book and all other Wrox books.
At the beginning of each chapter, you can find the location of the major code files for the chapter. Throughout each chapter, you can also find references to the names of code files as needed in listing titles and text.
Most of the code on www.wrox.com is compressed in a ZIP, RAR archive, or similar archive format appropriate to the platform. After you download the code, just decompress it with an appropriate compression tool.
NOTE Because many books have similar titles, you may find it easiest to search by ISBN; this book’s ISBN is 978-1-118-61209-5.
In addition to the code, on the website you will also find the sample test questions and answers included in this book, as well as additional sample test questions and answers not included in this book to help you practice for the 70-483 certification exam.
We make every effort to ensure that there are no errors in the text or in the code. However, no one is perfect, and mistakes do occur. If you find an error in one of our books, such as a spelling mistake or faulty piece of code, we would be grateful for your feedback. By sending in errata, you may save another reader hours of frustration, and at the same time, you can help us provide even higher quality information.
To find the errata page for this book, go to www.wrox.com/remtitle.cgi?isbn=1118612094 and click the Errata link. On this page you can view all errata that has been submitted for this book and posted by Wrox editors.
If you don’t spot “your” error on the Book Errata page, go to www.wrox.com/contact/techsupport.shtml and complete the form there to send us the error you have found. We’ll check the information, and if appropriate post a message to the book’s errata page and fix the problem in subsequent editions of the book.
For author and peer discussion, join the P2P forums at http://p2p.wrox.com. The forums are a web-based system for you to post messages relating to Wrox books and related technologies and interact with other readers and technology users. The forums offer a subscription feature to e-mail you topics of interest of your choosing when new posts are made to the forums. Wrox authors, editors, other industry experts, and your fellow readers are present on these forums.
At http://p2p.wrox.com, you can find a number of different forums that can help you, not only as you read this book, but also as you develop your own applications. To join the forums, just follow these steps:
Go to
http://p2p.wrox.com
and click the Register link.
Read the terms of use and click Agree.
Complete the required information to join and any optional information you want to provide, and click Submit.
You will receive an e-mail with information describing how to verify your account and complete the joining process.
NOTE You can read messages in the forums without joining P2P, but to post your own messages, you must join.
After you join, you can post new messages and respond to messages other users post. You can read messages at any time on the web. If you would like to have new messages from a particular forum e-mailed to you, click the Subscribe to This Forum icon by the forum name in the forum listing.
For more information about how to use the Wrox P2P, be sure to read the P2P FAQs for answers to questions about how the forum software works, as well as many common questions specific to P2P and Wrox books. To read the FAQs, click the FAQ link on any P2P page.
What You Will Learn in This Chapter
Getting certified
Understanding Microsoft certifications
Understanding Microsoft certification exams
Studying for the exam
This chapter is an introduction to Microsoft certifications in general and the Programming C# certification more specifically. In this chapter, you learn about the world of Microsoft certifications and why you might consider taking this exam and getting certified. The chapter also presents information on how exam questions are considered and written for Microsoft exams and describes how you can use this book to study for Exam 70-483.
A complete list of the topic areas that are covered on Exam 70-483 is also included to help you understand what to expect for objectives of each exam as you work toward your MCSD certification using the C# programming language.
Due to the nature of the content of Chapter 1, there are no code downloads for this chapter.
Certifications have been around for many years. Hardware manufacturers certify components, car dealers provide certified used cars, developers certify software to run on specific operating systems—and that’s just to name a few.
What this basically means is that the term certification can have many different definitions depending on the context in which it is used. In this book, certification refers to Microsoft certifications. (Specifics about Microsoft certification are presented in the section “What Is MS Certification?” later in this chapter.) Like many other large companies in the IT industry, Microsoft has established and maintains a certification program to show developers’ aptitude in designing and developing programs using Microsoft’s products.
Although each organization, including Microsoft, has its own certification program, benefits, and requirements, there are still a lot of similarities among certifications. For example, most, if not all organizations, deliver their certification exams through an exam delivery partner (EDP). This has typically been through EDPs such as Prometric, Pearson Vue, and Certiport.
Each program requires that the candidate register in the program and take specific exams and meet certain requirements before the participant is awarded a certification. Some programs require one exam for a certification credential, and others require multiple exams. For example, Cisco, Microsoft, Adobe, Novell, and Oracle all have certifications you can earn by taking one knowledge-based exam. Some certifications are more difficult than others.
The more complex, multi-exam scenarios are found in the high-end certifications such as the Microsoft Certified Master (MCM), which is changing to Microsoft Certified Solutions Master (MCSM), or Cisco Certified Internetworking Expert (CCIE) certifications. These certifications and exams require much more than just a knowledge-based exam. These certifications require a candidate to complete lab-based portions, meaning that the participant performs actual tasks in either a real or emulated environment.
For the Cisco exam, you visit the testing center and configure the necessary network switches, routers, and firewalls according to a specification. The exam team then introduces bugs, or essentially breaks your configuration, and you have to troubleshoot the issues and fix it.
The MCM program has different requirements depending on the certification you are seeking. For most of the MCM certifications, you attend classroom training, take knowledge-based exams, and take a final lab-based exam over a 21-day period—that is, 21 days straight with no breaks in between. Some of the MCM programs permit the candidate to take training at different institutions and then take the requisite knowledge-based exams with a final performance-based lab-style exam at the end, hosted by Prometric.
Obviously, the more stringent the requirements for a certification, the more credibility the certification holds in the industry. It also means a higher cost, but with that rigorous certification in hand, you can also demand—and usually get—more money for consulting fees or a higher salary. But that is getting into the next section: why you should get certified.
Obviously, if you purchased this book, you have already decided to get a certification, or at least take a certification exam. Of course you may also be just borrowing the book because you are curious about what might be involved in getting certified. Either way, this section describes some of the reasons why you might consider getting certified.
Having spent a lot of time pursuing certifications in the past, plus working as a Certification Product Planner, the reasons I have come across are varied and many. For the most part, to the reasons are summarized and rationalized for why certifications are good and why you may want to pursue them.
In the IT industry, especially in the realm of the developer world, most of the programmers who have been in the industry for some time came through academia and hold university degrees, typically in computer science. When you think about it, a Bachelor or Master’s degree is a certification from a certain perspective. The degree shows the world that the person whose name is indicated on the degree certificate has met the requirements as set forth by a board of some sort, usually the university faculty and a governing body.
Not every programmer, database developer, database administrator, or other IT professional, however, has attended a four-year degree program at a university. Many have instead taken classes at two-year certificate programs. Whatever the institution or schooling background, upon successfully completing the program, students acquire a diploma, certificate, degree, or other named piece of documentation that indicates they have achieved some specific level of knowledge.
One of the problems that graduates face after completing these programs is that the knowledge they gained during the course of their schooling is actually outdated to a certain extent. You might think computer science concepts don’t change at their core, and to a great extent, you are correct. But what does change are the technology and tools IT professionals use every day in their pursuit of the computer science career upon which they have embarked. A good example of this is how the Internet and the World Wide Web have changed your concept of what an application is. Just in the short lifespan of the web, you have seen the technology change from static pages with hyperlinks to pages supporting Cascading Style Sheets, JavaScript, ActiveX controls, server-side programming, state-management, and so on. None of these technologies or concepts were taught just a short time ago, yet they are relevant and important today.
Employers looking to hire programmers for developing websites that contain these technologies require some way to identify who has those skills. The Bachelor of Science document certainly doesn’t indicate this. Actually, there isn’t any way for an employer to know what courses a holder of a degree has actually taken unless the student provides a transcript. There isn’t any way to show an employer what knowledge and skills were gained after attending a university either outside of a resume or perhaps a portfolio.
Industry certifications are a way to address some of these issues. When properly implemented, secured, and executed on, industry certifications are an effective way to show existing and potential employers some important information. Certifications can provide the person who holds the credential, the following benefits:
Validation of knowledge
Validation of skills
A way to show continuing education
A means to prove a commitment to maintaining skills
Whatever your reasons for pursuing a certification, you must understand the value of the certification you intend to acquire and perhaps even the process by which the certifications are developed and maintained. The next few sections present an insight into Microsoft certifications, including what certifications Microsoft makes available, how they fit into the overall certification portfolio for Microsoft, and an insider’s view of how the certifications are planned, created, and delivered.
Many opponents to certifications cite reasons such as exam piracy and brain dumps for their opposition. Some indicate that employers don’t value certifications, and therefore they aren’t worth the money you would spend on them. Others, such as programmers, tell you that they don’t work in a world of multiple choices, so a multiple-choice test isn’t representative of their skills and knowledge.
Microsoft is not the only company affected by exam piracy and brain dumps. Any certification program is subject to these same issues. Although there are certain methods in existence to help deal with these problems, they can never be totally eradicated.
Microsoft is actively taking steps to counter some of these issues by performing exam analysis, in the form of statistical forensics, to help identify cheaters and exam centers that are at the heart of the problem. Over the past few years, it has been successful in shutting down testing centers that participate in exam piracy and websites that contribute to brain-dump activities. Because of the way the Internet works, however, it is impossible to completely stop all the brain-dump sites.
One of the best ways to help combat these issues is through the use of education and cooperation with certified professionals. Any time someone asks you for a brain dump or a way to cheat on a Microsoft exam, ensure that you explain the benefit of achieving the certification honestly and report any cheating activity to Microsoft. You can help drive the acceptance of your certifications and help to improve the reputation of these exams by helping to reduce exam piracy and cheating.
Microsoft certifications have evolved over the years. The exams have changed in their content, and the process for creating the exams has changed somewhat as well. Like most certification programs, the changes are based on customer feedback, changes in the industry, and standards board certifications.
Microsoft certifications are most commonly known as MCP certifications. MCP stands for Microsoft Certified Professional. To understand the Microsoft certification landscape, look at some terminology, what certifications are available from Microsoft, and how to obtain them.
Throughout this chapter, the terms certification and credential are used interchangeably. A certification is defined as a “title” that candidates can use after they complete the requirements set forth for that certification. Credential is another word for a certification. Again, it is a title that candidates can use after completing the requirements for that credential.
An example of a certification would be Microsoft Certified Solutions Associate (MCSA), Microsoft Certified Solutions Developer (MCSD), Microsoft Certified Solutions Expert (MCSE), or Microsoft Certified Solutions Master (MCSM). The following sections describe each of these designations.
The MCSD and older Microsoft Certified Systems Engineer (MCSE) certifications served the industry well for many years. Like all programs, changes and improvements were a necessity. Some of these changes were brought about by the need to streamline requirements and simplify the program, whereas other driving reasons were employers and hiring managers.
As technology changes, IT professionals either keep their skills up to date or they do not. This can create a bit of an issue for hiring managers trying to discern qualifications from resumes submitted. For example, programmers could indicate that they hold an MCSD certification, but don’t tell the hiring manager what programming language was used to achieve the credential. If the hiring manager is looking for a developer who could program using C++, the certification didn’t actually tell them that. Also, what elective exam did candidates use? How much web experience did they have as opposed to Windows development experience?
Both candidates and hiring managers provided feedback to Microsoft, telling them that it was not easy to determine just what the certification name meant or what requirements were needed for a certification. The elective system made it difficult to determine qualifications. Other feedback indicated that one certification didn’t necessarily map to the way the industry thought about job roles and skills qualifications.
As a result of this feedback and industry research, Microsoft made changes to the program and created new certifications and new exams to help address these issues and needs. It termed this new program the New Generation of Certifications and labeled the old system as Legacy Certifications. Then, just a few short years following that change, Microsoft introduced the current version of certifications, which is the third iteration of the certification, or cert, program. These changes are not designed to confuse you, but instead are intended to help ensure that your credentials have validity and meaning in the workforce.
The first iteration of the Microsoft certification program created a base credential known as MCP. This was the starting point for any of the higher certifications that consisted of:
MCSE
MCSD
MCDBA (Microsoft Database Administrator)
These were the mainstream certifications that existed in version one of the Microsoft certification programs. They served Microsoft well for a number of years, and these three credentials became well known in the industry.
As with any program, there is the potential not to meet the needs of every concerned party. Feedback to, and research by, Microsoft Learning resulted in some changes to the certification program. The changes were designed to address a couple of key areas: job roles and knowledge validation.
Both of these areas have some commonality. Hiring managers needed a way to identify which specific technologies a potential job candidate might have, and they needed a way to map the certifications to job roles. Only developer certifications are covered here.
For validating knowledge on a technical subject, Microsoft created the Microsoft Certified Technology Specialist (MCTS) credential. The MCTS certification is not considered to be an entry-level certification but is aimed at candidates who want to prove their knowledge and skills on a specific Microsoft technology.
To achieve an MCTS certification, the candidate would have to pass one or more exams. The MCTS certifications and exams also allowed Microsoft to provide a more valid way of testing candidates’ knowledge and skills on a technology by permitting them to include more complete coverage of that technology. To explain this a little better, consider how the older MCSD certification focused on either web or Windows development, which is not bad, except that these two platforms encompass a lot of different programming skill sets.
By using the MCTS exam focus and the different technologies that Microsoft was releasing, adequate coverage of each different technology could now be included in a separate exam. This allowed Microsoft to provide sufficient coverage of a technology on an exam and also clearly state what that technology is. Candidates passing that exam would have proven their knowledge and skills on that technology. Hiring managers now had a way to determine what the job candidate was certified on.
Microsoft also created another layer of certification known as the professional level. This credential is titled Microsoft Certified Professional Developer (MCPD). To achieve an MCPD credential, the candidate must pass any prerequisite MCTS certifications along with the MCPD exam.
The MCPD exams are designed to test a candidate’s ability to work as a team lead or development lead and make decisions around application designs. There are also not as many MCPD credentials as there are MCTS credentials, and this is to support the fact that they are intended to focus on a job role as opposed to a breadth of technologies.
The current version of Microsoft certifications changes the focus a bit more by looking at credentials such as Specialist and Solutions Experts or Solutions Developers. The changes made for the current set of credentials were designed to do the following:
Reduce the number of entry points
Reduce the number of certifications
Clarify certification paths
Enable single base certification to lead to multiple advanced certifications
Streamline the program into a seamless process
Again, the reasons for changing the certification program were in response to industry feedback and research. As noted in the preceding list, the previous generations of certifications were still confusing due to the number of entry points into the program, with multiple paths and many different certifications and exams. The current program focuses on three levels of certification.
There are three main tiers in the latest certification program:
Solutions Associate level
: Designed to be the foundation for certifications in Microsoft proving technical skills.
Solutions Expert level
: Expands on the knowledge of those at the Associate level and requires more rigor in the exams and knowledge tested. Candidates at this level should be able to build solutions using multiple technologies including cloud computing.
Solutions Master level
: The top of the Microsoft certification program. Consists of certifications that require knowledge-based exams along with performance-based testing. Those who hold a Masters certification demand higher salaries.
All the preceding certifications can be thought of as the technical certifications. Think of technical certifications as a set of exams and credentials intended to validate skills. There is another set of credentials that fall under the acronym MTA (Microsoft Technology Associate).
Actually, Microsoft is careful not to actually refer to the MTA as a certification. It is more of a certificate. The MTA is aimed at high school students and post-secondary institutions that offer two-year certificate programs; although, four-year universities can certainly deliver them as well.
Although the exams are technical in nature, they are designed to be entry level, and 80 percent of the content is intended to be knowledge level as opposed to implementation-specific. What that means is the questions are designed to test candidates on their understanding of the concepts, such as the following:
What is a class in object-oriented programming(OOP)?
What is a tuple in a database?