O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

C# 7.0 All-in-One For Dummies

Book Description

Sharpen your knowledge of C#

C# know-how is a must if you want to be a professional Microsoft developer. It's also good to know a little C# if you're building tools for the web, mobile apps, or other development tasks. C# 7.0 All-in-One For Dummies offers a deep dive into C# for coders still learning the nuances of the valuable programming language. Pop it open to get an intro into coding with C#, how to design secure apps and databases, and even pointers on building web and mobile apps with C#.

C# remains one of the most in-demand programming language skills. The language regularly ranks in the top five among "most in-demand" languages, typically along with Java/JavaScript, C++, and Python. A December 2016 ZDNet article noted 'If your employer is a Microsoft developer, you better know C#." Lucky for you, this approachable, all-in-one guide is here to help you do just that—without ever breaking a sweat!

Includes coverage of the latest changes to C#

  • Shows you exactly what the language can (and can't) do
  • Presents familiar tasks that you can accomplish with C#
  • Provides insight into developing applications that provide protection against hackers

If you have a basic understanding of coding and need to learn C#—or need a reference on the language in order to launch or further your career—look no further.

Table of Contents

    1. Cover
    2. Introduction
      1. About This Book
      2. Foolish Assumptions
      3. Icons Used in This Book
      4. Beyond the Book
      5. Where to Go from Here
    3. Book 1: The Basics of C# Programming
      1. Chapter 1: Creating Your First C# Console Application
        1. Getting a Handle on Computer Languages, C#, and .NET
        2. Creating Your First Console Application
        3. Making Your Console App Do Something
        4. Reviewing Your Console Application
        5. Introducing the Toolbox Trick
      2. Chapter 2: Living with Variability — Declaring Value-Type Variables
        1. Declaring a Variable
        2. What’s an int?
        3. Representing Fractions
        4. Handling Floating-Point Variables
        5. Using the Decimal Type: Is It an Integer or a Float?
        6. Examining the bool Type: Is It Logical?
        7. Checking Out Character Types
        8. What’s a Value Type?
        9. Comparing string and char
        10. Calculating Leap Years: DateTime
        11. Declaring Numeric Constants
        12. Changing Types: The Cast
        13. Letting the C# Compiler Infer Data Types
      3. Chapter 3: Pulling Strings
        1. The Union Is Indivisible, and So Are Strings
        2. Performing Common Operations on a String
        3. Comparing Strings
        4. What If I Want to Switch Case?
        5. Looping through a String
        6. Searching Strings
        7. Getting Input from the Command Line
        8. Controlling Output Manually
        9. Formatting Your Strings Precisely
        10. StringBuilder: Manipulating Strings More Efficiently
      4. Chapter 4: Smooth Operators
        1. Performing Arithmetic
        2. Performing Logical Comparisons — Is That Logical?
        3. Matching Expression Types at TrackDownAMate.com
      5. Chapter 5: Getting into the Program Flow
        1. Branching Out with if and switch
        2. Here We Go Loop-the-Loop
        3. Looping a Specified Number of Times with for
        4. Nesting Loops
        5. Don’t goto Pieces
      6. Chapter 6: Lining Up Your Ducks with Collections
        1. The C# Array
        2. Processing Arrays by Using foreach
        3. Sorting Arrays of Data
        4. Using var for Arrays
        5. Loosening Up with C# Collections
        6. Understanding Collection Syntax
        7. Using Lists
        8. Using Dictionaries
        9. Array and Collection Initializers
        10. Using Sets
        11. On Not Using Old-Fashioned Collections
      7. Chapter 7: Stepping through Collections
        1. Iterating through a Directory of Files
        2. Iterating foreach Collections: Iterators
        3. Accessing Collections the Array Way: Indexers
        4. Looping Around the Iterator Block
      8. Chapter 8: Buying Generic
        1. Writing a New Prescription: Generics
        2. Classy Generics: Writing Your Own
        3. Revising Generics
      9. Chapter 9: Some Exceptional Exceptions
        1. Using an Exceptional Error-Reporting Mechanism
        2. Throwing Exceptions Yourself
        3. Knowing What Exceptions Are For
        4. Can I Get an Exceptional Example?
        5. Assigning Multiple catch Blocks
        6. Planning Your Exception-Handling Strategy
        7. Grabbing Your Last Chance to Catch an Exception
        8. Throwing Expressions
      10. Chapter 10: Creating Lists of Items with Enumerations
        1. Seeing Enumerations in the Real World
        2. Working with Enumerations
        3. Creating Enumerated Flags
        4. Defining Enumerated Switches
    4. Book 2: Object-Oriented C# Programming
      1. Chapter 1: Object-Oriented Programming — What’s It All About?
        1. Object-Oriented Concept #1: Abstraction
        2. Object-Oriented Concept #2: Classification
        3. Why Classify?
        4. Object-Oriented Concept #3: Usable Interfaces
        5. Object-Oriented Concept #4: Access Control
        6. How C# Supports Object-Oriented Concepts
      2. Chapter 2: Showing Some Class
        1. Defining a Class and an Object
        2. Accessing the Members of an Object
        3. An Object-Based Program Example
        4. Discriminating between Objects
        5. Can You Give Me References?
        6. Classes That Contain Classes Are the Happiest Classes in the World
        7. Generating Static in Class Members
        8. Defining const and readonly Data Members
      3. Chapter 3: We Have Our Methods
        1. Defining and Using a Method
        2. A Method Example for Your Files
        3. Having Arguments with Methods
        4. Returning Values after Christmas
        5. Returning Multiple Values Using Tuples
      4. Chapter 4: Let Me Say This about this
        1. Passing an Object to a Method
        2. Defining Methods
        3. Accessing the Current Object
        4. Using Local Functions
      5. Chapter 5: Holding a Class Responsible
        1. Restricting Access to Class Members
        2. Why You Should Worry about Access Control
        3. Defining Class Properties
        4. Getting Your Objects Off to a Good Start — Constructors
        5. The C#-Provided Constructor
        6. Replacing the Default Constructor
        7. Using Expression-Bodied Members
      6. Chapter 6: Inheritance: Is That All I Get?
        1. Class Inheritance
        2. Why You Need Inheritance
        3. Inheriting from a BankAccount Class (a More Complex Example)
        4. IS_A versus HAS_A — I’m So Confused_A
        5. When to IS_A and When to HAS_A
        6. Other Features That Support Inheritance
        7. The object Class
        8. Inheritance and the Constructor
        9. The Updated BankAccount Class
      7. Chapter 7: Poly-what-ism?
        1. Overloading an Inherited Method
        2. Polymorphism
        3. The Class Business Card: ToString()
        4. C# During Its Abstract Period
        5. Sealing a Class
      8. Chapter 8: Interfacing with the Interface
        1. Introducing CAN_BE_USED_AS
        2. Knowing What an Interface Is
        3. Using an Interface
        4. Using the C# Predefined Interface Types
        5. Looking at a Program That CAN_BE_USED_AS an Example
        6. Unifying Class Hierarchies
        7. Hiding Behind an Interface
        8. Inheriting an Interface
        9. Using Interfaces to Manage Change in Object-Oriented Programs
      9. Chapter 9: Delegating Those Important Events
        1. E.T., Phone Home — The Callback Problem
        2. Defining a Delegate
        3. Pass Me the Code, Please — Examples
        4. A More Real-World Example
        5. Shh! Keep It Quiet — Anonymous Methods
        6. Stuff Happens — C# Events
      10. Chapter 10: Can I Use Your Namespace in the Library?
        1. Dividing a Single Program into Multiple Source Files
        2. Dividing a Single Program into Multiple Assemblies
        3. Putting Your Classes into Class Libraries
        4. Going Beyond Public and Private: More Access Keywords
        5. Putting Classes into Namespaces
      11. Chapter 11: Improving Productivity with Named and Optional Parameters
        1. Exploring Optional Parameters
        2. Looking at Named Parameters
        3. Dealing with Overload Resolution
        4. Using Alternative Methods to Return Values
      12. Chapter 12: Interacting with Structures
        1. Comparing Structures to Classes
        2. Creating Structures
        3. Using Structures as Records
    5. Book 3: Designing for C#
      1. Chapter 1: Writing Secure Code
        1. Designing Secure Software
        2. Building Secure Windows Applications
        3. Building Secure Web Forms Applications
        4. Using System.Security
      2. Chapter 2: Accessing Data
        1. Getting to Know System.Data
        2. How the Data Classes Fit into the Framework
        3. Getting to Your Data
        4. Using the System.Data Namespace
      3. Chapter 3: Fishing the File Stream
        1. Going Where the Fish Are: The File Stream
        2. StreamWriting for Old Walter
        3. Pulling Them Out of the Stream: Using StreamReader
        4. More Readers and Writers
        5. Exploring More Streams than Lewis and Clark
      4. Chapter 4: Accessing the Internet
        1. Getting to Know System.Net
        2. How Net Classes Fit into the Framework
        3. Using the System.Net Namespace
      5. Chapter 5: Creating Images
        1. Getting to Know System.Drawing
        2. How the Drawing Classes Fit into the Framework
        3. Using the System.Drawing Namespace
      6. Chapter 6: Programming Dynamically!
        1. Shifting C# Toward Dynamic Typing
        2. Employing Dynamic Programming Techniques
        3. Putting Dynamic to Use
        4. Running with the Dynamic Language Runtime
    6. Book 4: A Tour of Visual Studio
      1. Chapter 1: Getting Started with Visual Studio
        1. Versioning the Versions
        2. Installing Visual Studio
        3. Breaking Down the Projects
      2. Chapter 2: Using the Interface
        1. Designing in the Designer
        2. Paneling the Studio
        3. Coding in the Code Editor
        4. Using the Tools of the Trade
        5. Using the Debugger as an Aid to Learning
      3. Chapter 3: Customizing Visual Studio
        1. Setting Options
        2. Using Snippets
        3. Hacking the Project Types
    7. Book 5: Windows Development with WPF
      1. Chapter 1: Introducing WPF
        1. Understanding What WPF Can Do
        2. Introducing XAML
        3. Diving In! Creating Your First WPF Application
        4. Whatever XAML Can Do, C# Can Do Better!
      2. Chapter 2: Understanding the Basics of WPF
        1. Using WPF to Lay Out Your Application
        2. Arranging Elements with Layout Panels
        3. Exploring Common XAML Controls
      3. Chapter 3: Data Binding in WPF
        1. Getting to Know Dependency Properties
        2. Exploring the Binding Modes
        3. Investigating the Binding Object
        4. Editing, Validating, Converting, and Visualizing Your Data
        5. Finding Out More about WPF Data Binding
      4. Chapter 4: Practical WPF
        1. Commanding Attention
        2. Using Built-In Commands
        3. Using Custom Commands
        4. Using Routed Commands
    8. Book 6: Web Development with ASP.NET
      1. Chapter 1: Looking at How ASP.NET Works with C#
        1. Breaking Down Web Applications
        2. Questioning the Client
        3. Dealing with Web Servers
      2. Chapter 2: Building Web Applications
        1. Working in Visual Studio
        2. Developing with Style
      3. Chapter 3: Controlling Your Development Experience
        1. Showing Stuff to the User
        2. Getting Some Input from the User
        3. Data Binding
        4. Styling Your Controls
        5. Making Sure the Site Is Accessible
        6. Constructing User Controls
      4. Chapter 4: Leveraging the .NET Framework
        1. Surfing Web Streams
        2. Securing ASP.NET
        3. Managing Files
        4. Baking Cookies
        5. Tracing with TraceContext
        6. Navigating with Site Maps
    9. About the Author
    10. Advertisement Page
    11. Connect with Dummies
    12. End User License Agreement