Home > Store

C# Puzzlers (Video Training)

C# Puzzlers (Video Training)

Your browser doesn't support playback of this video. Please download the file to view it.

Downloadable Video

  • Sorry, this book is no longer in print.
  • About this video
  • Accessible from your Account page after purchase. Requires the free QuickTime Player software.

    Videos can be viewed on: Windows 8, Windows XP, Vista, 7, and all versions of Macintosh OS X including the iPad, and other platforms that support the industry standard h.264 video codec.

Not for Sale

Register your product to gain access to bonus material or receive a coupon.

Description

  • Copyright 2012
  • Edition: 1st
  • Downloadable Video
  • ISBN-10: 0-13-275698-6
  • ISBN-13: 978-0-13-275698-3

2+ Hours of Video Instruction

Overview

How well do you know C#? Put your knowledge to the test with Bill Wagner’s C# Puzzlers video LiveLesson!

Description

The C# language is more than a decade old, and that maturity means more complexity. This added complexity increases the chances for mistakes and unmaintainable code. Bill regularly presents “C# Puzzlers” at user groups and CodeMash events.  All the “puzzlers” in this LiveLesson have been put to the test with intermediate level developers who tried to break, workaround, and outsmart the code. 

C# Puzzlers exposes common misconceptions that can occur when developers are unclear about how language features interact or lack understanding about how a single features works. Using the fun “Puzzler” format, Bill demonstrates these misconceptions via screencasts using small code samples. He gives you an opportunity to figure it out first, and then explores different ways to modify the code until its behavior is correct.

This collection of Puzzlers is divided into six sections. Each section delves into the rules that govern the aspects of the C# language that developers find most confusing:

How the Puzzlers work:

1) Each puzzle shows a reasonably small piece of code, and then asks viewers to guess what the code does.

2) You take the opportunity to try and figure it out.

2) Bill then demonstrates what the code does, and why many developers believe it would behave differently.

3) To close out the lesson he discusses how you could write the code differently to accomplish the same result without the misconceptions.

About the Instructor

Bill Wagner has spent his entire career in the software industry, spanning both technical and business roles. Bill’s technical time is spent between curly braces, primarily with C#. He’s the author of the bestselling “Effective C#”, now in its second edition, and “More Effective C#”. His articles have appeared in MSDN Magazine, the C# Developer Center, Visual C++ Developer’s Journal, Visual Studio Magazine, ASP.NET Pro, .NET Developer’s Journal and more. He’s written hundreds of technical articles and actively blogs on technical and business topics.  Bill is also a Microsoft Regional Director.

He spent eight years as a self-employed consultant before co-founding SRT Solutions with Dianne Marsh. Over the past decade, SRT Solutions has grown into a premier software development company, amassing 4 FastTrack awards (2011, 2010, 2008, 2007), the Michigan 50 Companies to Watch award (2011), and making the Inc 500/5000 list (2011 and 2012). Bill was also awarded Automation Alley’s Emerging Technology Leader award in 2011.After a successful exit from SRT Solutions, Bill now spends his time helping developers improve their skills.

Skill Level

This topic should be of interest to anyone developing using the C# language. This includes Windows Server, Windows 8, Windows Phone, MonoDroid, and Mono Touch developers at the following skill level:

Intermediate

Topics Covered

  • Generics
  • Method Resolution
  • Named and Optional Parameters
  • LINQ
  • Value and Reference Semantics
  • Dynamic Programming in C#

Who Should Take This Course

Developers

C# programmers

Course Requirements

Some experience with C# programming.

Table of Contents

The introductory Puzzler introduces the format using a puzzle, and discusses some of the nuances of object construction.

Lesson I. Generics

Generics are still one of the most important aspects of the .NET environment and the C# language. So many of the features we use every day are built upon generics in one way or another. Generics are still a complicated feature. You must create code whose types are not known until runtime. The compiler must generate IL with minimal information about the actual types that will be represented by the type parameters. The JIT must convert that IL into executable code and plug in the real types for the type parameters. Finally, the meta data carried along must include information that enables reflection and other advanced techniques to work correctly.

Puzzle 1 - Operations on Generic Type Parameters

What information gets conveyed, and what information cannot get used when a real type is substituted for a type parameter?

Puzzle 2 - Generics and Specializations

What happens when you create overloads for generic methods?

Puzzle 3 - Generics and Variance

How do generics and arrays differ with respect to variance?

Puzzle 4 - Generics, Constraints and Overloads

How does the compile choose between different candidate generic methods?

Lesson II. Method Resolution

The rules that govern method resolution in C# are necessarily complex. The features the community has asked for and the team has implemented have only added more complexity to those rules with each new release of the C# language. If you want to be a strong C# developer, you need to have at least a working knowledge of these rules.

Puzzle 5 - Overloading base class methods

What happens when derived classes create overloads of base class methods?

Puzzle 6 - Overloaded methods and null parameters

How does the compiler resolve overloaded methods when you use null parameters?

Puzzle 7 - Overloaded methods and null parameters revisited

What if the overloaded parameter types are unrelated?

Puzzle 8 - Overloaded methods and null parameters and Generics

What if one of the methods is generic?

Lesson III. Named and Optional Parameters

Named and optional parameters sound so simple at first examination. But this feature has significant implications on other features in the language. It also has significant implications on areas as fundamental as how parameters are passed to called methods.

Puzzle 9 - Optional parameters and constructors

When is a default constructor not a default constructor?

Puzzle 10 - Optional Parameters and Overloads

Which is the better match?

Puzzle 11- Evaluation of Named Parameters

When do parameters get evaluated? Why does it matter?

Lesson IV. LINQ

LINQ introduced totally new ways of constructing and organizing programs. There were new rules related to how you wrote algorithms. Those rules still cause developers confusion in some cases.

Puzzle 12 - Bound Variables

When are LINQ queries evaluated?

Puzzle 13 - Method calls in LINQ queries

How does LINQ process expressions and method calls?

Lesson V. Value and Reference Semantics

Reference types and value types behave differently in many important ways. They also behave the same in many other ways. It can be difficult to keep those differences in mind as you get too accustomed to the similarities.

Puzzle 14 - Value type Semantics

When does copying values hurt?

Puzzle 15 - Value types and events

What happens when value types receive event notifications?

Lesson VI. Dynamic Programming in C#

Dynamic extensions move many of the common tasks that were performed by the compiler to runtime libraries. The interplay between static and dynamic typing creates new complications in C# programs. This section discusses some of the most common ways where static and dynamic types interact in ways that can be surprising.

Puzzle 16 - Dynamic Types and Extension Methods

How do dynamic types interact with extension methods?

Puzzle 17 - Anonymous types and Dynamic Methods

Under what conditions can anonymous types be treated dynamically?

Puzzle 18- Creating Dynamic Types in C#

Why would you pick different ways to implement dynamic types?

About LiveLessons Video Training

LiveLessons Video Training series publishes hundreds of hands-on, expert-led video tutorials covering a wide selection of technology topics designed to teach you the skills you need to succeed. This professional and personal technology video series features world-leading author instructors published by your trusted technology brands: Addison-Wesley, Cisco Press, IBM Press, Pearson IT Certification, Prentice Hall, Sams, and Que. Topics include: IT Certification, Programming, Web Development, Mobile Development, Home and Office Technologies, Business and Management, and more.  View all LiveLessons on InformIT at: http://www.informit.com/livelessons

Downloads

Downloads

Get all the downloads for the puzzles and solutions for C# Puzzler’s LiveLesson.

Sample Content

Table of Contents

The introductory Puzzler introduces the format using a puzzle, and discusses some of the nuances of object construction.

I.         Generics

Generics are still one of the most important aspects of the .NET environment and the C# language. So many of the features we use every day are built upon generics in one way or another. Generics are still a complicated feature. You must create code whose types are not known until runtime. The compiler must generate IL with minimal information about the actual types that will be represented by the type parameters.  The JIT must convert that IL into executable code and plug in the real types for the type parameters. Finally, the meta data carried along must include information that enables reflection and other advanced techniques to work correctly.

Puzzle 1 - Operations on Generic Type Parameters

 What information gets conveyed, and what information cannot get used when a real type is substituted for a type parameter?

Puzzle 2 - Generics and Specializations

What happens when you create overloads for generic methods?

Puzzle 3 - Generics and Variance

How do generics and arrays differ with respect to variance?

Puzzle 4 - Generics, Constraints and Overloads

How does the compile choose between different candidate generic methods?

II.        Method Resolution

The rules that govern method resolution in C# are necessarily complex. The features the community has asked for and the team has implemented have only added more complexity to those rules with each new release of the C# language. If you want to be a strong C# developer, you need to have at least a working knowledge of these rules.

Puzzle 5 - Overloading base class methods

What happens when derived classes create overloads of base class methods?

Puzzle 6 - Overloaded methods and null parameters

How does the compiler resolve overloaded methods when you use null parameters?

Puzzle 7 - Overloaded methods and null parameters revisited

What if the overloaded parameter types are unrelated?

Puzzle 8 - Overloaded methods and null parameters and Generics

What if one of the methods is generic?

III.      Named and Optional Parameters

Named and optional parameters sound so simple at first examination. But this feature has significant implications on other features in the language. It also has significant implications on areas as fundamental as how parameters are passed to called methods.

Puzzle 9 - Optional parameters and constructors

When is a default constructor not a default constructor?

Puzzle 10 - Optional Parameters and Overloads

Which is the better match?

Puzzle 11- Evaluation of Named Parameters

When do parameters get evaluated? Why does it matter?

IV.      LINQ

LINQ introduced totally new ways of constructing and organizing programs. There were new rules related to how you wrote algorithms.  Those rules still cause developers confusion in some cases.

Puzzle 12 - Bound Variables

When are LINQ queries evaluated?

Puzzle 13 - Method calls in LINQ queries

How does LINQ process expressions and method calls?

V.        Value and Reference Semantics

Reference types and value types behave differently in many important ways. They also behave the same in many other ways. It can be difficult to keep those differences in mind as you get too accustomed to the similarities.

Puzzle 14 - Value type Semantics

When does copying values hurt?

Puzzle 15 - Value types and events

What happens when value types receive event notifications?

VI.      Dynamic Programming in C#

Dynamic extensions move many of the common tasks that were performed by the compiler to runtime libraries. The interplay between static and dynamic typing creates new complications in C# programs.  This section discusses some of the most common ways where static and dynamic types interact in ways that can be surprising.

Puzzle 16 - Dynamic Types and Extension Methods

How do dynamic types interact with extension methods?

Puzzle 17 - Anonymous types and Dynamic Methods

Under what conditions can anonymous types be treated dynamically?

Puzzle 18- Creating Dynamic Types in C#

Why would you pick different ways to implement dynamic types?

Updates

Submit Errata

More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020