20483: Programming in C#

Length: 5 days | Audience: IT Professionals | Level: 200

About this course

This training course teaches developers the programming skills that are required for developers to create Windows applications using the C# language. During their five days in the classroom students review the basics of C# program structure, language syntax, and implementation details, and then consolidate their knowledge throughout the week as they build an application that incorporates several features of the .NET Framework 4.5.
The course introduces many of the techniques and technologies employed by modern desktop and enterprise applications, including:
  • Building new data types.
  • Handling events.
  • Programming the user interface.
  • Accessing a database.
  • Using remote data.
  • Performing operations asynchronously.
  • Integrating with unmanaged code.
  • Creating custom attributes.
  • Encrypting and decrypting data.
At the end of the course, students should leave the class with a solid knowledge of C# and how to use it to develop .NET Framework 4.5 applications.
This course uses Visual Studio 2012, running on Windows 8.

Audience profile

This course is intended for experienced developers who already have programming experience in C, C++, JavaScript, Objective-C, Microsoft Visual Basic®, or Java and understand the concepts of object-oriented programming.
This course is not designed for students who are new to programming; it is targeted at professional developers with at least one month of experience programming in an object-oriented environment.

At course completion

After completing this course, students will be able to:
  • Describe the core syntax and features of C#.
  • Create and call methods, catch and handle exceptions, and describe the monitoring requirements of large-scale applications.
  • Implement the basic structure and essential elements of a typical desktop application.
  • Create classes, define and implement interfaces, and create and use generic collections.
  • Use inheritance to create a class hierarchy, extend a .NET Framework class, and create generic classes and methods.
  • Read and write data by using file input/output and streams, and serialize and deserialize data in different formats.
  • Create and use an entity data model for accessing a database and use LINQ to query and update data.
  • Use the types in the System.Net namespace and WCF Data Services to access and query remote data.
  • Build a graphical user interface by using XAML.
  • Improve the throughput and response time of applications by using tasks and asynchronous operations.
  • Integrate unmanaged libraries and dynamic components into a C# application.
  • Examine the metadata of types by using reflection, create and use custom attributes, generate code at runtime, and manage assembly versions.
  • Encrypt and decrypt data by using symmetric and asymmetric encryption.

Module 1: Exploring ASP.NET MVC 4
The goal of this module is to outline to the students the components of the Microsoft Web Technologies stack, which can be used to host a completed web application. Students will also learn about ASP.NET 4.5 and be introduced to the web forms, web pages, and MVC programming models. Finally they will see an overview of ASP.NET MVC 4, including new features and configuration.

  • Overview of Microsoft Web Technologies
  • Overview of ASP.NET 4.5
  • Introduction to ASP.NET MVC 4

Lab: Exploring ASP.NET MVC 4

  • Exploring a Photo Sharing Application
  • Exploring a Web Pages Application
  • Exploring a Web Forms Application
  • Exploring an MVC Application

Module 2: Designing ASP.NET MVC 4 Web Applications
The goal of this module is to introduce students to the typical design process that architects must complete when they plan an MVC 4 application. At this stage in the design process, MVC 4 has been selected as the most appropriate programming model, but the details of the application, such as the overall architecture, Controllers, Views, Models, and routes to create, have not been fixed. How to plan such details is shown during this module.

  •  Planning in the Project Design Phase
  •  Designing Models, Controllers, and Views

Lab: Designing ASP.NET MVC 4 Web Applications

  • Planning Models
  • Planning Controllers
  • Planning Views
  • Architecting an MVC Application

Module 3: Developing ASP.NET MVC 4 Models
The goal of this module is to enable the students to create Models within an MVC application that implement the business logic necessary to satisfy business requirements. The module also describes how to implement a connection to a database, or alternative data store, using the Entity Framework and LINQ.

  • Creating MVC Models
  • Working with Data

Lab: Developing ASP.NET MVC 4 Models

  • Creating an MVC Project and Adding a Model
  • Creating a New SQL Azure Database in Visual Studio
  • Adding Properties and Methods to MVC Models
  • Using Display and Edit Annotations in MVC Models

Module 4: Developing ASP.NET MVC 4 Controllers
The goal of this module is to enable students to add Controllers to MVC applications and to implement actions that respond to user input and other events. The students will learn how Controllers relate to Models and how to implement Controller actions that define the View used to display or edit data. This module also covers how to write action filters that run code before or after multiple actions in the Controller. The students will learn about situations when action filters are useful.

  • Writing Controllers and Actions
  • Writing Action Filters

Lab: Developing ASP.NET MVC 4 Controllers

  • Adding an MVC Controller and Writing the Actions
  • Writing the Action Filters in a Controller
  • Using the Photo Controller

Module 5: Developing ASP.NET MVC 4 Views
The goal of this module is to describe the role of Views in an MVC web application and enable users to create and code them. The syntax of a Razor View is of critical importance for students to understand because it defines both the layout and the functionality of the data display. HTML Helpers will also be discussed in detail and common Helpers, such as Html.ActionLink() and Html.EditorFor(), will be described. Reusing code by defining Partial Views and Razor Helpers will be discussed as well.

  • Creating Views with Razor Syntax
  • Using HTML Helpers
  • Reusing Code in Views

Lab: Developing ASP.NET MVC 4 Views

  • Adding a View for Photo Display
  • Adding a View for New Photos
  • Creating and Using a Partial View
  • Adding a Home View and Testing the Views

Module 6: Testing and Debugging ASP.NET MVC 4 Web Applications
The goal of this module is to enable students to increase the resilience and quality of an application by locating and correcting code errors, bugs, and other unexpected results. MVC applications are well suited to unit testing techniques and these techniques ensure a high quality of code by systematically testing the functionality of each small component. In addition the debugging tools and exception handling available in Visual Studio will be explained.

  • Unit Testing MVC Components
  • Implementing an Exception Handling Strategy

Lab: Testing and Debugging the ASP.NET MVC 4 Web Applications

  • Performing Unit Tests
  • Configuring Exception Handling

Module 7: Structuring ASP.NET MVC 4 Web Applications
The goal of this module is to enable students to structure a web application in such a way that users can rapidly locate the information they need. Two aspects of the design are emphasized: the URLs presented in the browser address bar should be understandable and can be controlled by adding routes to the ASP.NET Routing Engine, and the navigation controls, such as menus and breadcrumb trails, should present the most relevant links to frequently read pages. Search Engine Optimization is important throughout this module.

  • Analyzing Information Architecture
  • Configuring Routes
  • Creating a Navigation Structure

Lab: Structuring ASP.NET MVC 4 Web Applications

  • Using the Routing Engine
  • Building Navigation Controls

Module 8: Applying Styles to ASP.NET MVC 4 Web Applications

The goal of this module is to explore how students can impose a consistent look and feel to an MVC application and share other common components, such as headers and footers, between all Views. Besides describing CSS styles and template views, the module will discuss how to migrate a look and feel created by a web designer into an MVC application. Techniques for adapting the display of a site for small screens and mobile devices will also be introduced. Lessons

  • Using Template Views
  • Applying CSS to an MVC Application
  • Creating an Adaptive User Interface

Lab: Applying Styles to ASP.NET MVC 4 Web Applications

  • Using Template Views
  • Applying a Consistent Look and Feel to an MVC Application
  • Adapting Webpages for Different Browsers


Module 9: Building Responsive Pages in ASP.NET MVC 4 Web Applications

The goal of this module is to describe to the students how partial page updates and caching can optimize the responsiveness of a web application. Students will see how to make use of AJAX helpers and partial views to update small portions of a page instead of refreshing the entire page. The module also covers the different caches developers can use to store rendered pages and discusses how to configure caching for maximum performance.


  • Using AJAX and Partial Page Updates
  • Implementing a Caching Strategy

Lab: Building Responsive Pages in ASP.NET MVC 4 Web Applications

  • Using Partial Page Updates
  • Configuring ASP.NET Caches


Module 10: Using JavaScript and jQuery for Responsive MVC 4 Web Applications

The goal of this module is to teach the students techniques that run code on the browser. This approach can increase the responsiveness of the application because a rendered page can respond to a user action without reloading the entire page from the server. Students will learn about the jQuery script library and how to use it to call web services and update user interface components.


  • Rendering and Running JavaScript Code
  • Using jQuery and jQueryUI

Lab: Using JavaScript and jQuery for Responsive MVC 4 Web Applications

  • Using jQuery to Respond to Users
  • Using jQueryUI to Build a User Interface


Module 11: Controlling Access to ASP.NET MVC 4 Web Applications

The goal of this module to ensure good security in terms of strong authentication and authorization for access. The lessons describe how to enable anonymous users to create their own user account and gain privileged access to content.


  • Implementing Authentication and Authorization
  • Assigning Roles and Membership

Lab: Controlling Access to ASP.NET MVC 4 Web Applications

  • Configuring Authentication
  • Controlling Access to Resources
  • Providing User Account Facilities


Module 12: Building a Resilient ASP.NET MVC 4 Web Application

The goal of this module is to enable the students to build applications that are stable and reliable. Such applications are not vulnerable to common hacking techniques such as cross-site scripting and also store state information such as the contents of a shopping cart and user preferences. This state information is preserved when servers or browsers restart, connections are lost, and other connectivity issues occur.


  • Developing Secure Sites
  • State Management

Lab: Building a Resilient ASP.NET MVC 4 Web Application

  • Storing User Preferences
  • Using User Preferences in the Photo Gallery


Module 13: Using Windows Azure Web Services in ASP.NET MVC 4 Web Applications

The goal of this module is to introduce Windows Azure to the students and explain why a developer would write a Windows Azure service instead of code in a web application. Students will also see how to write such a service and call it from a web application or from other applications, such as a mobile device app.


  • Introduction to Windows Azure
  • Designing and Writing Windows Azure Services
  • Consuming Windows Azure Services in a Web Application

Lab: Using Windows Azure Web Services in ASP.NET MVC 4 Web Applications

  • Creating and Coding a Windows Azure Service
  • Consuming Data from a Windows Azure Service


Module 14: Implementing Web APIs in ASP.NET MVC 4 Web Applications 

The goal of the module is to introduce the concept of a Web API to students and to describe how to make an application’s core functionality more broadly available for integration into other web and mobile applications. Students will learn about the new Web API feature of MVC 4 and see how to build a RESTful Web API and call it from other applications.


  • Developing a Web API
  • Calling a Web API from Mobile and Web Applications

Lab: Implementing Web APIs in ASP.NET MVC 4 Web Applications

  • Developing a Web API in MVC 4
  • Adding Routes and Controllers to Handle REST Requests
  • Calling RESTful services from Client-Side Code


Module 15: Handling Requests in ASP.NET MVC 4 Web Applications

The goal of this module is to describe how to write components that intercept requests from browsers before they are received by MVC Controllers. These components include HTTP Modules, HTTP Handlers, and the Web Sockets protocol. The module describes scenarios in which developers use such components and shows how to add them to an MVC application.


  • Using HTTP Modules and HTTP Handlers
  • Using Web Sockets

Lab: Handling Requests in ASP.NET MVC 4 Web Applications

  • Writing a Web Handler that Uses Web Sockets
  • Building a Chat Room in the Photo Sharing Application


Module 16: Deploying ASP.NET MVC 4 Web Applications

The goal for this module is to enable students to deploy a completed MVC application to a web server or Windows Azure. The module begins by describing testing, staging, and production deployments and the web server environments required for each. It also describes the advantages and disadvantages of using Windows Azure to host the application. Students also see all the available deployment options in Visual Studio.


  • Deploying Web Applications
  • Deploying MVC 4 Applications

Lab: Deploying ASP.NET MVC 4 Web Applications

  • Deploying an Application to Windows Azure
  • Testing the Completed Application
Developers attending this course should already have gained some limited experience using C# to complete basic programming tasks. More specifically, students should have hands-on experience using C# that demonstrates their understanding of the following:
  • How to name, declare, initialize and assign values to variables within an application.
  • How to use:
    • arithmetic operators to perform arithmetic calculations involving one or more variables;
    • relational operators to test the relationship between two variables or expressions;
    • logical operators to combine expressions that contain relational operators.
  • How to create the code syntax for simple programming statements using C# language keywords and recognize syntax errors using the Visual Studio IDE.
  • How to create a simple branching structure using an IF statement.
  • How to create a simple looping structure using a For statement to iterate through a data array.
  • How to use the Visual Studio IDE to locate simple logic errors.
  • How to create a Function that accepts arguments (parameters and returns a value of a specified type.
  • How to design and build a simple user interface using standard controls from the Visual Studio toolbox.
  • How to connect to a SQL Server database and the basics of how to retrieve and store data.
  • How to sort data in a loop.
  • How to recognize the classes and methods used in a program.