You are previewing Sams Teach Yourself C# 5.0 in 24 Hours.
O'Reilly logo
Sams Teach Yourself C# 5.0 in 24 Hours

Book Description

In just 24 sessions of one hour or less, learn how to build great Windows Store apps, Windows desktop applications, and Web applications with C# 5.0. Using this tutorial’s straightforward, step-by-step approach, you’ll master everything from the absolute basics to the newest innovations, so you can solve real problems with C#. One step at a time, you’ll learn core techniques like flow control and error handling, construct complete solutions with Visual Studio, use advanced features like attributes and dynamic types, and even build engaging, immersive Windows Store apps. Each lesson builds on what you’ve already learned, giving you a strong real-world foundation for success, even if you’ve never programmed with C# 5.0 before!

Step-by-step instructions carefully walk you through the most common C# programming tasks.
Quizzes and exercises at the end of each chapter help you test your knowledge.
Notes and tips present interesting information related to the discussion.
Cautions alert you to possible problems and give you advice on how to avoid them.

Learn how to...

  • Gain a holistic understanding of C# 5.0, .NET, and Visual Studio 2012

  • Use classes and objects “the C# way”

  • Master the C# type system, inheritance, interfaces, and abstract classes

  • Define, initiate, respond to, and send data through events

  • Work with loops, strings, regular expressions, and collections

  • Ensure type safety and promote code reuse with generics and collections

  • Work with data in all forms, from file systems and streams to XML and databases

  • Use advanced features such as attributes, dynamic types, and anonymous functions

  • Build and debug C# applications with Visual Studio 2012

  • Create state-of-the-art Windows Store apps with the async pattern

  • Improve performance and reliability by managing memory more effectively

  • Build more responsive software with threads, concurrency, and parallelism

  • Table of Contents

    1. Title Page
    2. Copyright Page
    3. Contents at a Glance
    4. Table of Contents
    5. Foreword
    6. About the Author
    7. Dedication
    8. Acknowledgments
    9. We Want to Hear from You
    10. Reader Services
    11. Introduction
      1. Audience and Organization
      2. Conventions Used in This Book
      3. Source Files
      4. Closing Thoughts
    12. Part I: C# Fundamentals
      1. Hour 1. The .NET Framework and C#
        1. The .NET Framework
        2. The C# Language
        3. Summary
        4. Q&A
        5. Workshop
        6. Exercises
      2. Hour 2. Introducing Visual Studio
        1. Introducing the Visual Studio Editions
        2. Writing Your First Program
        3. Debugging in Visual Studio
        4. Visualizing Data
        5. Commenting Your Code
        6. Summary
        7. Q&A
        8. Workshop
        9. Exercises
      3. Hour 3. Understanding C# Types
        1. An Overview of Types
        2. The C# Predefined Types
        3. Other Commonly Used Types
        4. Working with Operators
        5. Default Values
        6. Null and Nullable Types
        7. Casting and Conversion
        8. Summary
        9. Q&A
        10. Workshop
        11. Exercises
      4. Hour 4. Understanding Classes and Objects the C# Way
        1. Object-Oriented Programming
        2. Component-Oriented Programming
        3. Classes in C#
        4. Scope and Declaration Space
        5. Nested Classes
        6. Partial Classes
        7. Static Classes
        8. Object Initializers
        9. Summary
        10. Q&A
        11. Workshop
        12. Exercises
      5. Hour 5. Inheritance, Interfaces, and Abstract Classes
        1. Inheritance and Polymorphism
        2. Abstract Classes and Members
        3. Working with Interfaces
        4. Summary
        5. Q&A
        6. Workshop
        7. Exercises
      6. Hour 6. Creating Enumerated Types and Structures
        1. Enumerated Types
        2. Working with Structures
        3. Summary
        4. Q&A
        5. Workshop
        6. Exercises
      7. Hour 7. Events and Event Handling
        1. Understanding Events
        2. Subscribing and Unsubscribing
        3. Publishing an Event
        4. Raising an Event
        5. Summary
        6. Q&A
        7. Workshop
        8. Exercises
    13. Part II: Programming in C#
      1. Hour 8. Controlling Program Flow
        1. Understanding the Selection Statements
        2. Iteration Statements
        3. Jump Statements
        4. Summary
        5. Q&A
        6. Workshop
        7. Exercises
      2. Hour 9. Using Strings and Regular Expressions
        1. Strings
        2. Mutable Strings Using StringBuilder
        3. Type Formatting
        4. Regular Expressions
        5. Summary
        6. Q&A
        7. Workshop
        8. Exercises
      3. Hour 10. Working with Arrays and Collections
        1. Single and Multidimensional Arrays
        2. Indexers
        3. Generic Collections
        4. Collection Initializers
        5. Collection Interfaces
        6. Enumerable Objects and Iterators
        7. Summary
        8. Q&A
        9. Workshop
        10. Exercises
      4. Hour 11. Handling Errors Using Exceptions
        1. Understanding Exceptions
        2. System.Exception
        3. Throwing Exceptions
        4. Handling Exceptions
        5. Rethrowing Caught Exceptions
        6. Overflow and Integer Arithmetic
        7. Exceptions, Code Contracts, and Parameter Validation
        8. Summary
        9. Q&A
        10. Workshop
        11. Exercises
      5. Hour 12. Understanding Generics
        1. Why You Should Use Generics
        2. Using Generic Methods
        3. Creating Generic Classes
        4. Combining Generics and Arrays
        5. Variance in Generic Interfaces
        6. Working with Tuples
        7. Summary
        8. Q&A
        9. Workshop
        10. Exercises
      6. Hour 13. Understanding Query Expressions
        1. Introducing LINQ
        2. Using LINQ to Manipulate Data
        3. Standard Query Operator Methods
        4. Deferred Execution
        5. Summary
        6. Q&A
        7. Workshop
        8. Exercises
    14. Part III: Working with Data
      1. Hour 14. Using Files and Streams
        1. Files and Directories
        2. Reading and Writing Data
        3. Summary
        4. Q&A
        5. Workshop
        6. Exercises
      2. Hour 15. Working with XML
        1. Understanding the XML DOM
        2. Using LINQ to XML
        3. Selecting and Querying XML
        4. Modifying XML
        5. Summary
        6. Q&A
        7. Workshop
        8. Exercises
      3. Hour 16. Working with Databases
        1. Prerequisites
        2. Understanding ADO.NET
        3. Understanding LINQ to ADO.NET
        4. Summary
        5. Q&A
        6. Workshop
        7. Exercises
    15. Part IV: Building an Application Using Visual Studio
      1. Hour 17. Building a Windows Application
        1. Understanding WPF
        2. Creating a WPF Application
        3. Styling the Layout
        4. Summary
        5. Q&A
        6. Workshop
        7. Exercises
      2. Hour 18. Using Data Binding and Validation
        1. Understanding Data Binding
        2. Converting Data
        3. Validating Data
        4. Working with Data Templates
        5. Summary
        6. Q&A
        7. Workshop
        8. Exercises
      3. Hour 19. Building Windows Store Apps
        1. Understanding the Windows Runtime
        2. What’s a Windows Store App?
        3. Working Asynchronously
        4. Building an App
        5. Summary
        6. Q&A
        7. Workshop
        8. Exercises
      4. Hour 20. Building a Web Application
        1. Understanding Web Application Architecture
        2. Working with ASP.NET
        3. Creating a Web Application
        4. Understanding Data Validation
        5. Summary
        6. Q&A
        7. Workshop
        8. Exercises
    16. Part V: Diving Deeper
      1. Hour 21. Programming with Attributes
        1. Understanding Attributes
        2. Using the Caller Info Attributes
        3. Working with the Common Attributes
        4. Using Custom Attributes
        5. Accessing Attributes at Runtime
        6. Summary
        7. Q&A
        8. Workshop
        9. Exercises
      2. Hour 22. Dynamic Types and Language Interoperability
        1. Using Dynamic Types
        2. Understanding the DLR
        3. Interoperating with COM
        4. Reflection Interoperability
        5. Summary
        6. Q&A
        7. Workshop
        8. Exercises
      3. Hour 23. Memory Organization and Garbage Collection
        1. Memory Organization
        2. Garbage Collection
        3. Understanding the IDisposable Interface
        4. Using the Dispose Pattern
        5. Declaring and Using Finalizers
        6. Summary
        7. Q&A
        8. Workshop
        9. Exercises
      4. Hour 24. Understanding Threads, Concurrency, and Parallelism
        1. Understanding Threads and Threading
        2. Concurrency and Synchronization
        3. Understanding the Task Parallel Library
        4. Working with Parallel LINQ (PLINQ)
        5. Potential Pitfalls
        6. Summary
        7. Q&A
        8. Workshop
        9. Exercises
    17. Index
    18. Ad Pages