Customer Service 1-800-221-5528

Murach’s C# 2015

by Anne Boehm and Joel Murach
26 chapters, 884 pages, 387 illustrations
Published February 2016
ISBN 978-1-890774-94-3
List price: $57.50

This is the latest edition of our best-selling C# book, which has been used by software developers and in programming curricula since 2004.

It focuses on how to develop professional Windows Forms applications with C#. But along the way, it teaches the C# language and core skills that are needed for building any C# application…for Windows, the web, or mobile devices. And although this book is designed for introductory C# courses, it also works for object-oriented and database programming courses.

Buy this book

You are currently on the Murach site for instructors. To buy this book, please visit our retail site.

Best C# book ever. Murach manuals are precise and to the point, with lots and lots of examples. Highly recommended for beginners."

Posted at an online bookseller

  • About this Book
  • Table of Contents
  • Courseware
  • FAQs
  • Corrections

Book description

Section 1: Introduction to program development

The three chapters of section 1 show your students how to use the Visual Studio IDE to develop Windows Forms applications. In particular, these chapters focus on the skills for designing forms and entering code. These are essential skills your students need to get the most out of Visual Studio.

Section 2: Language essentials

The eight chapters of section 2 present a professional subset of C# that includes all of the core programming skills for developing business applications. That includes the best techniques for handling exceptions, validating data, and debugging applications.

Section 3: Object-oriented programming

The five chapters of section 3 present a professional set of skills for creating and using classes. The first chapter in this section, chapter 12, presents the basic skills every student should know. Because the other chapters present advanced skills, you may want to be selective about which of these chapters or portions of chapters you assign.

Section 4: Database programming

The four chapters of section 4 present the essential skills for developing applications that work with databases. That includes using Visual Studio’s data sources feature to develop database applications quickly and easily. It also includes the basic skills for using ADO.NET code to work with databases.

Section 5: More skills for working with data

The four chapters of section 5 present some additional skills for developing applications that work with data. That includes skills for working with text, binary, and XML files, the basic skills for using LINQ to query a data structure, and an introduction to using the Entity Framework to work with database data through an Entity Data Model. You can decide which of these chapters you want to include in your course, and you can assign them in the sequence that works best for you, as long as you cover LINQ before going on to the Entity Framework.

Section 6: Enhancement and deployment

The two chapters in the last section of the book add some professional polish to your students’ C# skills. One shows how to enhance a user interface with features like menus and toolbars, while the other presents options for deploying applications. Like the chapters in section 5, you can decide how much of this material to assign and in what sequence.

What courses this book can be used for

This is the Visual Studio 2015 edition of our core C# book that’s designed for introductory C# courses. But it also works for object-oriented and database programming courses, so you may want to consider it for a two- or three-course sequence.

Introductory courses

For an introductory course, this book gives your students a realistic view of how Visual Studio and C# are used to develop Windows Forms applications. By the time your students complete chapter 7, for example, they will be able to develop bulletproof applications that do data validation and exception handling. And by the time they complete chapter 12, they’ll be able to develop object-oriented applications.

Advanced courses

For advanced courses, you’re really going to be hard-pressed to find a better book:

  • In sections 1 and 2, your students can review the essential skills that they often don’t learn in introductory courses that use other books.
  • In section 3, your students can learn all of the intricacies of object-oriented programming.
  • In section 4, your students can learn how to develop Windows database applications.
  • In section 5, your students can learn how to work with other types of data. This section covers text, binary, and XML files, how to query data using LINQ, and how to start using the Entity Framework.
  • In section 6, your students can polish their professional skills by learning how to enhance the user interface and deploy an application.

And because sections 3 through 6 are modular, you can teach them in whatever sequence you prefer.

Presentation options

After your students complete the first 12 chapters of this book, you can go on to any other section in the book. This works because these sections are written as independent modules that require only the first 12 chapters as a prerequisite. In addition, most of the chapters in sections 4, 5, and 6 are independent of each other, so they can be taught in any order. That’s what we mean by “modularity,” and that lets you create the course that’s right for your students.

The main points here are that (1) you don’t need to teach the chapters in sequence and (2) you get to decide the focus of your course. If, for example, you want to emphasize the complexities of object-oriented programming, assign all of section 3. If you want to emphasize database programming, assign all of section 4. If you want to teach a course that introduces all aspects of programming, assign selected chapters from sections 3, 4, 5, and 6.

“There’s too much content for my course”

That’s a complaint we sometimes hear about our books, and we realize it may be an issue with an almost 900-page book!

Remember, though, that the modular structure of this book lets you assign just the content that you want for your course, whether it’s a beginning or advanced course. Remember too that all our books are priced fairly so students not only buy them but keep them for use on the job later on. In fact, at $57.50, your students are likely to get their money back many times over in job opportunities and pay raises.

Book features

Like all our books, this one has features that you won’t find in competing books. That’s why we believe that your students will learn faster and better with our book than with any other. Here are just two of those features.

  • Unlike some C# books, this book shows your students how to get the most from Visual Studio 2015. Since using the features of this IDE is one of the keys to development productivity, this also helps your students get more value out of the exercises and projects.
  • Unlike most C# books that are used for introductory courses, our book shows how to develop real-world applications. In the first two sections, for example, the students learn how to create bulletproof applications with data validation. Although many C# books never get to that level, our book takes that approach right on through the next four sections.

What’s new in this edition

Frankly, not much has changed when it comes to using C# and Visual Studio to develop Windows applications. That means that it will be easy to upgrade to this edition if you’ve been using a previous edition.

However, we have added material on Live Code Analysis, CodeLens, expression-bodied functions, interpolated strings, and the null-conditional operator, all new in VS 2015. We’ve added material on lambdas. We’ve added an introductory chapter on the Entity Framework. And we’ve dropped the chapter on developing Windows 8 apps.

What software your students need for this book

To develop Windows Forms applications with C# 2015, you can have your students use one of the following:

  • Visual Studio 2015 Community Edition; this is the free edition that can be downloaded from Microsoft’s website
  • Professional Edition or Enterprise Edition of Visual Studio 2015; these editions are designed for development teams and are priced accordingly

These editions all come with everything your students need to develop the Windows Forms applications presented in this book. That includes the Visual Studio development environment, version 4.6 of the Microsoft .NET Framework, C# 2015, and a simplified version of SQL Server called SQL Server Express LocalDB.

We used the Professional Edition as the basis for this book, but you’ll find that it has just a few minor differences from the Community Edition. And these differences don’t affect how you develop applications with Visual Studio. So all of the skills your students learn and all of the applications they develop with the Community Edition will still work with the other editions of Visual Studio.

Appendix A of the book shows your students how to install any of the Visual Studio 2015 editions on their own PCs.

What people say about this book

“There are plenty of books on C# and the .NET framework. What sets this apart is the Murach style of teaching.
     “I have a limited background as a programmer and I needed both an intro to a powerful language as well as a primer on the concepts of object-oriented programming. I have learned more in the 800+ pages of this book than I have reading half a dozen other books and hours of forum posts online.”
- Posted at an online bookseller

“This is a great book to introduce C# programming…. It’s an 883-page book, but it is very easy to read following the traditional ‘Murach Style’ where you learn something on the left page and you can immediately review the short summary, code samples, and effective explanations on the right page.”
- James Lin, SoCal Developer Network

“Murach's book format and content are hard to beat. The format of left page detail and right page code sample is extremely useful, especially for those new to the subject matter at hand. I often recommend Murach's books to those that are just picking up various Microsoft based technologies or that are looking to improve their skills to an intermediate level.”
- Posted at an online bookseller

“If you've read a Murach book, then you're familiar with the format. My habit is to read everything on topics that I don't know much or anything about, and just skim the right pages for topics that I'm more familiar with. I like this format because it makes it easier to find areas that I need to read without going through everything.”
- William Springer, Vulcan Ears Book Reviews

“This is a great training manual to get newbies up to speed.”
- Ian Ippolito, PlanetSourceCode

View the table of contents for this book in a PDF: Table of Contents (PDF)

Click on any chapter title to display or hide its content.

Section 1 An introduction to Visual Studio

Chapter 1 How to get started with Visual Studio

An introduction to .NET development

.NET applications

Visual Studio and the .NET programming languages

The .NET Framework

The Visual Studio IDE

How a C# application is compiled and run

How C# differs from the other .NET languages

How C# differs from Java

A tour of the Visual Studio IDE

How to start Visual Studio

How to open or close an existing project

Some possible menu variations

How to use the Form Designer

How to use the Code Editor

How to use the Solution Explorer

How to work with Visual Studio’s windows

How to test a project

How to build a project

How to run a project

How to upgrade projects and change .NET Framework versions

How to upgrade projects created in earlier versions of C#

How to change the .NET Framework version used by a project

Chapter 2 How to design a Windows Forms application

How to set options and create a new project

How to set the Visual Studio options

How to change the import and export settings

How to create a new project

How to design a form

The design of the Invoice Total form

How to add controls to a form

How to set properties

Common properties for forms and controls

How to add navigation features

The property settings for the Invoice Total form

How to use Document Outline view

How to name and save the files of a project

How to name the files of a project

How to save the files of a project

Chapter 3 How to code and test a Windows Forms application

An introduction to coding

Introduction to object-oriented programming

How to refer to properties, methods, and events

How an application responds to events

How to add code to a form

How to create an event handler for the default event of a form or control

How to delete an event handler

How IntelliSense helps you enter the code for a form

The event handlers for the Invoice Total form

How to detect and correct syntax errors

More coding skills

How to code with a readable style

How to code comments

How to work with the Text Editor toolbar

How to collapse or expand blocks of code

How to zoom in and out

How to highlight symbols

How to print the source code

How to use code snippets

How to refactor code

How to use the annotations in the scroll bar

How to get help information

How to run, test, and debug a project

How to run a project

How to test a project

How to debug runtime errors

Section 2 The C# language essentials

Chapter 4 How to work with numeric and string data

How to work with the built-in value types

The built-in value types

How to declare and initialize variables

How to declare and initialize constants

How to code arithmetic expressions

How to code assignment statements

How to work with the order of precedence

How to use casting

How to use the Math class

How to work with strings

How to declare and initialize a string

How to join and append strings

How to include special characters in strings

How to convert data types

The .NET structures and classes that define data types

How to use methods to convert data types

How to use methods to convert numbers to formatted strings

Three other skills for working with data

How to work with scope

How to declare and use enumerations

How to work with nullable types and the null-coalescing operator

Two versions of the Invoice Total application

The basic Invoice Total application

The enhanced Invoice Total application

Chapter 5 How to code control structures

How to code Boolean expressions

How to use the relational operators

How to use the logical operators

How to code conditional statements

How to code if-else statements

How to code switch statements

An enhanced version of the Invoice Total application

How to code loops

How to code while and do-while loops

How to code for loops

Loops that use break and continue statements

Debugging techniques for programs with loops

The Future Value application

The design and property settings for the form

The code for the form

Chapter 6 How to code methods and event handlers

How to code and call methods

How to code methods

How to call methods

How to use optional parameters

How to use named arguments

How to use refactoring to create a new method and its calling statement

When and how to pass arguments by reference and by value

How to work with events and delegates

How to generate an event handler for any event

How event wiring works

How to handle multiple events with one event handler

Another version of the Future Value application

The event handlers and the CalculateFutureValue method

Some of the generated code

Chapter 7  How to handle exceptions and validate data

An introduction to exceptions

How exceptions work

How to display a dialog box

How to use structured exception handling

How to catch an exception

How to use the properties and methods of an exception

How to catch specific types of exceptions

How to throw an exception

The Future Value application with exception handling

How to validate data

How to validate a single entry

How to use generic methods to validate an entry

How to validate multiple entries

The Future Value application with data validation

The dialog boxes

The code

Chapter 8  How to use arrays and collections

How to work with one-dimensional arrays

How to create an array

How to assign values to the elements of an array

How to work with arrays

How to use foreach loops to work with arrays

How to work with rectangular arrays

How to create a rectangular array

How to assign values to a rectangular array

How to work with rectangular arrays

How to work with jagged arrays

How to create a jagged array

How to assign values to a jagged array

How to work with jagged arrays

More skills for working with arrays

How to use the Array class

How to refer to and copy arrays

How to code methods that work with arrays

How to use the null-conditional operator

How to work with collections

Commonly used collection classes

Typed vs. untyped collections

How to work with a list

How to work with a sorted list

How to work with queues and stacks

How to work with an array list

Chapter 9 How to work with dates and strings

How to work with dates and times

How to create a DateTime value

How to get the current date and time

How to format DateTime values

How to get information about dates and times

How to perform operations on dates and times

How to work with strings

The properties and methods of the String class

Code examples that work with strings

More code examples that work with strings

How to use the Parse and TryParse methods to validate numeric entries

How to use the StringBuilder class

How to format numbers, dates, and times

How to format numbers

How to format dates and times

How to use interpolated strings

Chapter 10 More skills for working with Windows forms and controls

How to work with controls

Five more types of controls

How to work with combo boxes and list boxes

How to work with check boxes and radio buttons

How to work with group boxes

How to use Tab Order view to set the tab order

How to get the information you need for using a control

How to work with multi-form projects

How to add a form to a project

The code that’s generated for a new form

How to rename a form

How to display the first form of an application

How to display a form as a dialog box

How to pass data between a form and a custom dialog box

How to use the MessageBox class

How to display a dialog box and get the user response

How to use the FormClosing event

The Payment application

The operation

The property settings

The code for the Customer form

The code for the Payment form

Chapter 11 How to debug an application

Basic debugging techniques

How to set the debugging options

How to work in break mode

How to use the Edit and Continue feature

How to work with data tips

How to use breakpoints

How to control the execution of an application

How to use the debugging windows

How to use the Locals window to monitor variables

How to use the Autos window to monitor variables

How to use Watch windows to monitor expressions

How to use the Immediate window to execute commands

How to use the Call Stack window to monitor called methods

How to use the Call Hierarchy window to navigate through your code

How to use the Output window to view project information

How to write data to the Output window

How use the Visualizer dialog boxes to view strings

Section 3 Object-oriented programming

Chapter 12 How to create and use classes

An introduction to classes

How classes can be used to structure an application

The members you can define within a class

The code for the Product class

How instantiation works

Basic skills for creating a class

How to add a class file to a project

How to code fields

How to code properties

How to code methods

How to code constructors

How to code static members

The Product Maintenance application

The operation of the Product Maintenance application

The classes used by the Product Maintenance application

The code for the Product Maintenance application

More skills for creating a class

How to code auto-implemented properties

How to code expression-bodied properties and methods

How to generate code stubs

How to browse, diagram, and display and edit classes

How to browse the classes in a solution

How to use class diagrams and the Class Details window

How to use the Peek Definition window

How to work with structures

How to create a structure

How to use a structure

Chapter 13 How to work with indexers, delegates, events, and operators

An introduction to the ProductList class

The code for a simple ProductList class

The specifications for the enhanced ProductList class

How to work with indexers

How to create an indexer

How to throw an argument exception

How to work with delegates and events

How to define and use a delegate

How to define and use events

How to use anonymous methods and lambda expressions with delegates and events

How to overload operators

An introduction to operator overloading

How to overload arithmetic operators

How to overload relational operators

An enhanced version of the Product Maintenance application

The code for the ProductList class

The code for the Product Maintenance form

Chapter 14 How to work with inheritance

An introduction to inheritance

How inheritance works

How the .NET Framework uses inheritance

Methods inherited from the System.Object class

How to use inheritance in your applications

Basic skills for working with inheritance

How to create a base class

How to create a subclass

How polymorphism works

An inheritance version of the Product Maintenance application

The operation of the Product Maintenance application

The code for the Product, Book, and Software classes

The code for the ProductList class

The code for the Product Maintenance form

The code for the New Product form

Object types and casting

How to use the Type class to get information about an object’s type

How to use casting with inheritance

How to work with abstract and sealed classes

How to work with abstract classes

How to work with sealed classes

Chapter 15 How to work with interfaces and generics

How to work with interfaces

An introduction to interfaces

Some of the interfaces defined by the .NET Framework

How to create an interface

How to implement an interface

A Product class that implements the ICloneable interface

How to use an interface as a parameter

How to work with generics

How to code a class that defines a generic collection

Some of the generic interfaces defined by the .NET Framework

How to implement the IComparable<> interface

How to use constraints

How to implement the IEnumerable<> interface

How to code an interface that uses generics

Chapter 16 How to organize and document your classes

How to organize your classes

How to code multiple classes in a single file

How to split a single class across multiple files

How to work with namespaces

How to document your classes

How to add XML documentation to a class

How to view the XML documentation

How to create and use class libraries

How class libraries work

How to create a class library project

How to add a reference to a class library

How to use the classes in a class library

Section 4 Database programming

Chapter 17 An introduction to database programming

An introduction to client/server systems

The hardware components of a client/server system

The software components of a client/server system

An introduction to relational databases

How a table is organized

How the tables in a database are related

How the columns in a table are defined

The design of the MMABooks database

How to use SQL to work with a relational database

How to query a single table

How to join data from two or more tables

How to add, update, and delete data in a table

An introduction to ADO.NET

The .NET data providers

How the basic ADO.NET components work

Concurrency and the disconnected data architecture

How a dataset is organized

How to work with data without using a data adapter

Two ways to create ADO.NET objects

Chapter 18 How to work with data sources and datasets

How to create a data source

How to use the Data Sources window

How to start the Data Source Configuration Wizard

How to choose a data source type

How to choose the database model for a data source

How to choose the connection for a data source

How to create a connection to a database

How to save a connection string in the app.config file

How to choose database objects for a data source

The schema file created by the Data Source Configuration Wizard

How to use a data source

How to generate a DataGridView control from a data source

A Product Maintenance application that uses a DataGridView control

How to change the controls associated with a data source

How to generate detail controls from a data source

A Customer Maintenance application that uses TextBox controls

How to handle data errors

How to handle data provider errors

How to handle ADO.NET errors

How to handle data errors for a DataGridView control

How to use the Dataset Designer

How to view the schema for a dataset

How to use the Query Builder

How to preview the data for a query

How to interpret the generated SQL statements

Chapter 19 How to work with bound controls and parameterized queries

How to work with bound text boxes and combo boxes

How to format the data displayed in a text box

How to bind a combo box to a data source

How to use code to work with a binding source

How to work with parameterized queries

How to create a parameterized query

How to use code to work with a parameterized query

How to work with the ToolStrip control

How to use the Items Collection Editor

How to code an event handler for a ToolStrip item

An enhanced Customer Maintenance application

The user interface

The code

How to work with a DataGridView control

How to modify the properties of a DataGridView control

How to edit the columns of a DataGridView control

How to format the data in the columns of a DataGridView control

How to use a DataGridView control to create a Master/Detail form

A Customer Invoice Display application

The user interface

The dataset schema

The code for the Customer Invoices form

Chapter 20 How to use ADO.NET to write your own data access code

How to work with connections and commands

How to create and work with connections

How to create and work with commands

How to create and work with parameters

How to use parameters in SQL statements

How to create parameters

How to work with parameters

How to execute commands

How to create and work with a data reader

How to execute queries that return a single value

How to execute action queries

A Customer Maintenance application that uses commands

The user interface

The class diagram for the business and database classes

The code for the CustomerDB class

The code for the StateDB class

The code for the MMABooksDB class

The code for the Customer Maintenance form

The code for the Add/Modify Customer form

Section 5 More skills for working wth data

Chapter 21 How to work with files and data streams

An introduction to the System.IO classes

The classes for managing directories, files, and paths

How files and streams work

How to use the FileStream class

How to use the exception classes for file I/O

How to work with text files

How to write a text file

How to read a text file

A class that works with a text file

How to work with binary files

How to write a binary file

How to read a binary file

A class that works with a binary file

Chapter 22 How to work with XML files

An introduction to XML

An XML document

XML tags, declarations, and comments

XML elements

XML attributes

How to work with the XML Editor

How to create a new XML file

How to open an existing XML file

How to edit an XML file

How to work with XML

How to use the XmlWriter class

Code that writes an XML document

How to use the XmlReader class

How the XmlReader class reads nodes

Code that reads an XML document

A class that works with an XML file

Chapter 23 How to use LINQ

Basic concepts for working with LINQ

How LINQ is implemented

Advantages of using LINQ

The three stages of a query operation

How to code query expressions

How to identify the data source for a query

How to filter the results of a query

How to sort the results of a query

How to select fields from a query

How to join data from two or more data sources

How to use extension methods and lambda expressions

How extension methods work

Extension methods used to implement LINQ functionality

How lambda expressions work

How to use lambda expressions with extension methods

A Customer Invoice application that uses generic lists

The user interface

The code for the form

A Customer Invoice application that uses a typed dataset

The dataset schema

The code for the form

Chapter 24 How to use the Entity Framework

How to create an Entity Data Model

How the Entity Framework works

How to start an Entity Data Model with the Entity Data Model Wizard

How to choose the Entity Framework version

How to choose the database objects

The Entity Data Model in the Entity Data Model Designer

How to use the Entity Data Model Designer

Basic skills for using the designer

How to use the Model Browser window

How to use the Mapping Details window

How to use LINQ to Entities

How to retrieve data from a single table

How to query across relationships

How to load related objects

How to insert, update, and delete data

How to update an existing row

How to delete an existing row

How to add a new row

How to provide for concurrency

How to use bound controls with entities

How to create an object data source

How to bind controls

A Customer Maintenance application

The user interface

The Entity Data Model

The code for the MMABooksEntity class

The code for the Customer Maintenance form

The code for the Add/Modify Customer form

Section 6 Enhancement and deployment

Chapter 25 How to enhance the user interface

Two types of user interfaces

A single-document interface (SDI)

A multiple-document interface (MDI)

How to develop SDI applications

How to use a startup form

How to use a Tab control

How to add menus to a form

How to create menus

How to set the properties that work with menu items

How to write code that works with menu items

How to develop MDI applications

How to create parent and child forms

How to write code that works with parent and child forms

How to add toolbars to a form

How to create a toolbar

How to write code that works with toolbars

How to add help information

How to add tool tips

How to add context-sensitive help

Chapter 26 How to deploy an application

An introduction to deploying Windows applications

How XCopy works

How ClickOnce works

How a Setup program works

How to use XCopy

How to create a release build

How to copy the release build to the client machine

How to use ClickOnce

How to publish an application

How to select the files that are published

How to select the prerequisites

How to set the update options

How to set the publish options

How to install an application

How to update an application

How to create and use a Setup program

How to create an InstallShield project

How to use the InstallShield Project Assistant

How to add output files to an InstallShield project

How to create and view the installation files for a Setup program

How to use a Setup program to install an application

How to deploy database applications

Using ClickOnce deployment

Using a Setup program

Appendix A How to install and use the software for this book

How to use the downloadable files

How to install Visual Studio 2015

How to use the MMABooks database

If you aren’t already familiar with the supporting courseware that we provide for a book, please go to About our Courseware. As you will see, our courseware consists of the end-of-chapter activities in the book, the files in the student download at our retail site, and the instructor’s materials. These components provide everything that other publishers provide in a way that delivers better results.

If you are familiar with our courseware, here’s a quick summary of the courseware for this book. For a detailed description in PDF format, please read the Instructor’s Summary.

End-of-chapter activities in the book

  • Term lists
  • Practice exercises

Student download at our retail site

  • Source code and data for the applications in the book
  • Starting code for the exercises in the book
  • Solutions to the book exercises

Appendix A in the book gives your students complete instructions for downloading and installing these items on their PCs.

Instructor’s materials

  • Instructional objectives by chapter
  • PowerPoint slides for classroom presentations
  • Test banks in multiple formats
  • A second full set of chapter-by-chapter exercises that aren’t in the book, plus their solutions
  • Student projects and model solutions
  • The files that students can download at our retail site: (1) source code for the book applications, (2) starting code for the exercises in the book, and (3) solutions to the exercises in the book

On this page, we’ll be posting answers to the questions that come up most often about this book. So if you have any questions that you haven’t found answered here at our site, please e-mail us. Thanks!

 

There are no book corrections that we know of at this time. But if you find any, please email us, and we'll post any corrections that affect the technical accuracy of the book here. Thank you!

Murach college books and courseware since 1974