You are previewing Beginning Visual C# 2012 Programming.

Beginning Visual C# 2012 Programming

Cover of Beginning Visual C# 2012 Programming by Karli Watson... Published by Wrox
  1. Cover
  2. Contents
  3. Part I: The C# Language
    1. Chapter 1: Introducing C#
      1. What Is the .NET Framework?
      2. What Is C#?
      3. Visual Studio 2012
      4. Summary
    2. Chapter 2: Writing A C# Program
      1. The Visual Studio 2012 Development Environment
      2. Console Applications
      3. Desktop Applications
      4. Summary
    3. Chapter 3: Variables and Expressions
      1. Basic C# Syntax
      2. Basic C# Console Application Structure
      3. Variables
      4. Expressions
      5. Summary
    4. Chapter 4: Flow Control
      1. Boolean Logic
      2. The goto Statement
      3. Branching
      4. Looping
      5. Summary
    5. Chapter 5: More About Variables
      1. Type Conversion
      2. Complex Variable Types
      3. String Manipulation
      4. Summary
    6. Chapter 6: Functions
      1. Defining and Using Functions
      2. Variable Scope
      3. The Main( ) Function
      4. Struct Functions
      5. Overloading Functions
      6. Using Delegates
      7. Summary
    7. Chapter 7: Debugging and Error Handling
      1. Debugging in Visual Studio
      2. Error Handling
      3. Summary
    8. Chapter 8: Introduction to Object-Oriented Programming
      1. What Is Object-Oriented Programming?
      2. OOP Techniques
      3. OOP in Desktop Applications
      4. Summary
    9. Chapter 9: Defining Classes
      1. Class Definitions in C#
      2. System.Object
      3. Constructors and Destructors
      4. OOP Tools in Visual Studio
      5. Class Library Projects
      6. Interfaces Versus Abstract Classes
      7. Struct Types
      8. Shallow Copying Versus Deep Copying
      9. Summary
    10. Chapter 10: Defining Class Members
      1. Member Definitions
      2. Additional Class Member Topics
      3. Interface Implementation
      4. Partial Class Definitions
      5. Partial Method Definitions
      6. Example Application
      7. The Call Hierarchy Window
      8. Summary
    11. Chapter 11: Collections, Comparisons, and Conversions
      1. Collections
      2. Comparisons
      3. Conversions
      4. Summary
    12. Chapter 12: Generics
      1. What Are Generics?
      2. Using Generics
      3. Defining Generic Types
      4. Variance
      5. Summary
    13. Chapter 13: Additional OOP Techniques
      1. The :: Operator and the Global Namespace Qualifier
      2. Custom Exceptions
      3. Events
      4. Expanding and Using CardLib
      5. Attributes
      6. Summary
    14. Chapter 14: C# Language Enhancements
      1. Initializers
      2. Type Inference
      3. Anonymous Types
      4. Dynamic Lookup
      5. Advanced Method Parameters
      6. Extension Methods
      7. Lambda Expressions
      8. Caller Information Attributes
      9. Summary
  4. Part II: Windows Programming
    1. Chapter 15: Basic Desktop Programming
      1. XAML
      2. The Playground
      3. Control Layout
      4. The Game Client
      5. Summary
    2. Chapter 16: Advanced Desktop Programming
      1. The Main Window
      2. Creating and Styling Controls
      3. WPF User Controls
      4. Putting It All Together
      5. Summary
    3. Chapter 17: Windows Store Apps
      1. Getting Started
      2. Windows Store Apps versus Desktop Applications
      3. Developing Windows Store Apps
      4. App Development
      5. Converting KarliCards, Part 1
      6. Common Elements of Windows Store Apps
      7. Converting KarliCards, Part 2
      8. The Windows Store
      9. Summary
    4. Chapter 18: Deploying Desktop Applications
      1. Deployment Overview
      2. ClickOnce Deployment
      3. InstallShield Limited Edition
      4. Summary
  5. Part III: Web Programming
    1. Chapter 19: ASP.NET Web Programming
      1. Overview of Web Applications
      2. ASP.NET Runtime
      3. Creating a Simple Page
      4. Server Controls
      5. ASP.NET Postback
      6. ASP.NET AJAX Postback
      7. Input Validation
      8. State Management
      9. Styles
      10. Master Pages
      11. Site Navigation
      12. Authentication and Authorization
      13. Reading from and Writing to a SQL Server Database
      14. Summary
    2. Chapter 20: Deploying Web Applications
      1. Internet Information Services
      2. IIS Configuration
      3. Copying a Website
      4. Publishing a Web Application
      5. Summary
  6. Part IV: Data Access
    1. Chapter 21: File System Data
      1. Streams
      2. The Classes for Input and Output
      3. Serialized Objects
      4. Monitoring the File System
      5. Summary
    2. Chapter 22: XML
      1. XML Documents
      2. Using XML in Your Application
      3. Summary
    3. Chapter 23: Introduction to LINQ
      1. First LINQ Query
      2. Using the LINQ Method Syntax
      3. Ordering Query Results
      4. Understanding the orderby Clause
      5. Ordering Using Method Syntax
      6. Querying a Large Data Set
      7. Using Aggregate Operators
      8. Querying Complex Objects
      9. Projection: Creating New Objects in Queries
      10. Projection: Method Syntax
      11. Using the Select Distinct Query
      12. Using the Any and All Methods
      13. Ordering by Multiple Levels
      14. Multi-Level Ordering Method Syntax: ThenBy
      15. Using Group Queries
      16. Using Take and Skip
      17. Using First and FirstOrDefault
      18. Using the LINQ Set Operators
      19. Using Joins
      20. Summary
    4. Chapter 24: Applying LINQ
      1. LINQ Varieties
      2. Using LINQ with Databases
      3. Installing SQL Server and the Northwind Sample Data
      4. First LINQ to Database Query
      5. Navigating Database Relationships
      6. Using LINQ with XML
      7. LINQ to XML Functional Constructors
      8. Saving and Loading an XML Document
      9. Working with XML Fragments
      10. Generating XML from Databases
      11. How to Query an XML Document
      12. Using LINQ to XML Query Members
      13. Summary
  7. Part V: Additional Techniques
    1. Chapter 25: Windows Communication Foundation
      1. What Is WCF?
      2. WCF Concepts
      3. WCF Programming
      4. Summary
    2. Chapter 26: Windows Workflow Foundation
      1. Hello World
      2. Workflows and Activities
      3. Arguments and Variables
      4. Custom Activities
      5. Summary
  8. Appendix A: Exercise Solutions
  9. Introduction
  10. Advertisement
O'Reilly logo

Chapter 8

Introduction to Object-Oriented Programming

WHAT YOU WILL LEARN IN THIS CHAPTER

  • What object-oriented programming is
  • How to use OOP techniques
  • How desktop applications rely on OOP

WROX.COM CODE DOWNLOADS FOR THIS CHAPTER

You can find the wrox.com code downloads for this chapter at www.wrox.com/remtitle.cgi?isbn=9781118314418 on the Download Code tab. The code is in the Chapter 8 download and individually named according to the names throughout the chapter.

At this point in the book, you’ve covered all the basics of C# syntax and programming, and have learned how to debug your applications. Already, you can assemble usable console applications. However, to access the real power of the C# language and the .NET Framework, you need to make use of object-oriented programming (OOP) techniques. In fact, as you will soon see, you’ve been using these techniques already, although to keep things simple we haven’t focused on this.

This chapter steers away from code temporarily and focuses instead on the principles behind OOP. This leads you back into the C# language because it has a symbiotic relationship with OOP. All of the concepts introduced in this chapter are revisited in later chapters, with illustrative code — so don’t panic if you don’t grasp everything in the first read-through of this material.

To start with, you’ll look at the basics of OOP, which include answering that most fundamental of questions, “What is an object?” You will quickly find that a lot of terminology ...

The best content for your career. Discover unlimited learning on demand for around $1/day.