
This course will teach you how to program the C# language on Microsoft Windows. This video gives you a quick overview of what to expect from the course.
This is the course text to download.
This document contains links to useful downloads, sources of information and news of developments related to C# programming.
A summary of section One of this course
If you are a Visual Studio 2019 user, be sure to download and read this document before creating a project.
If you are impatient to get started, this video will guide you through all the steps from starting Visual Studio to running your program. Follow along to see how to design a user interface and write some simple C# code.
How to create a user interface with Visual Studio
How to add code to respond to events
What you need to do to use the code in the archive
This video explains some of the differences between editions of Visual Studio. It also explains how to customize the software by changing everything from the items on the menus to the formatting of your code.
Familiarize yourself with the essential features of the Visual Studio environment such as the Design View, Code Editor, Properties and Events panels, Alignment Toolbar and Solution Explorer.
You can follow this course on a Mac (or on Linux) using the free MonoDevelop IDE and Mono framework. Alternatively, you can run Visual Studio in a Virtual Machine, such as Parallels, on a Mac.
Web links:
http://www.parallels.com/
http://monodevelop.com
This lecture explains how to load and run the Visual Studio solutions provided in the source code archive into MonoDevelop (or Xamarin Studio) on a Mac.
This is where I explain the essential features of the C# language: data types, variables, constants, functions, keywords, namespaces, type conversion and other important components of the language
Every piece the data in your programs has data type. That’s what this lesson is all about.
Here we look at how to assign data items to named variables.
While variables – whose values can be changed - are essential in programming, sometimes you may want to make sure that a value cannot be changed.
How to document your code.
C# defines a number of special words, keywords, that mean specific things to the language.
A function is a named block of code that can be run by calling its name.
How to use code stored in other files.
How to use some of the built-in routines to convert between data types.
As well as using methods to convert between different types, you can ‘cast’ one type to another – with some restrictions.
C# also allows you to declare and initialize local variables without specifying a type
Let’s now summarise some of the essential elements and syntax of C#.
How to program a simple calculator.
How to run code only if some test condition is true.
How to run different bits of code when you test if something is or is not true.
How to run just one line of code after a test. And do curly brackets matter?
How to make a second test if the first one fails.
If you need to perform a number of tests, it is often quicker to write them as ‘switch statements’.
Operators are special symbols that are used to do specific operations such as add¬ition, multiplication and concatenation.
The operators you need to do calculations in C#.
How to compare two values.
How to test If X is true AND Y is true. Or if either X OR Y is true.
Operators that do arithmetic and assignment in one go.
The ++ and – operators.
What is the difference between ++a and a++?
How to handle the order in which tests are evaluated.
Multiple test conditions: good, bad or incomprehensible?
Let’s summarise what we’ve learnt about operators.
In this step I’m going to explain all about functions or methods and arguments
Here we look at functions: named blocks of code.
Is a method the same as a function?
How to send data items to a function.
How to return data from a function.
The different types of argument that you can use in C#.
And one more argument type.
Multiple functions with the same name. How does that work?
Functions inside functions…
A sample program showing some of the concepts we’ve discussed
Download this PDF guide to learn more about the details of the TreeView sample project described in the previous lesson.
Functions that call themselves.
Let’s quickly revise what you’ve learnt in this step of the course.
This is where things start to get really interesting. Object Orientation.
What are classes and objects?
Create a blueprint for an object.
Create an object based on the class defined in the last lesson
How to be sure an object has been created
The Visual Studio refactoring tool
This is a hands-on guide to writing code to create a simple ‘family tree’ of related classes.
Visual Studio can automate the separation of classes into code files
Methods that create an object from a class
Keywords that change scope and visibility
Special types of method that access fields of an object
Does it matter what your call the things in your programs?
Let’s quickly go over what we’ve learnt in this section.
In this step we look at arrays, indexing and iteration.
Arrays – sequential collections of elements
How to count over list items in a loop
You can create arrays of any type of object, strings, integers, doubles or even user-defined objects
Another common way of iterating over items in an array in C# is to use a foreach loop.
Strings can be treated as arrays of characters
Using ‘while’ loops to program a word counting utility
An alternative type of ‘while’ loop
A simple text editor that you can use as a basis for adding features such as our word counter tool
Strings in C# can be manipulated using built-in methods
There is another string-like class called StringBuilder that you need to be aware of
How to embed values into a format string
C# also lets you evaluate expressions right inside a string
A quick overview of what we learnt about arrays and strings in this section
In step 7 we find out how to save and load files to and from a disk.
How to test if a file exists, copy a file and display file information using static methods.
How to use methods to find information and do operations on your disk files and directories
Streams provide numerous special routines for saving and loading data
How to save and load text data
So what use is file handling in your own projects?
Some types of project that you might want to try to program on your own
What you’ve learnt in this step
Here you can download the source code of a complex C# Launchpad application that lets you start up programs, documents and files by clicking buttons on a form. This program illustrates numerous programming techniques. You will learn:
How to drag files and directories out of the Windows Explorer
How to create buttons and controls at runtime
Huw to extract and display icons for documents and programs
How to attach event-handers in code to respond to events such as clicks
How to create a Recently-Opened File menu
How to attach event-handlers to menu items at runtime
How to save and restore application properties between sessions
How to create XML-format configuration files
….and much more
This is a great project for intermediate-level programmers. Not only will it teach you a broad range of coding techniques but it also provides you with a genuinely useful application which you may continue to develop by adding your own code.
In this step we are coming back to take a closer look at classes and methods.
One class in several files – that’s a partial class
Some more variations on methods
Classes can be static too!
How to use static and overloaded methods
Structures and enumerated constants
What we learnt in step 8…
What to do when programs go wrong
To trap errors at runtime, you need to handle exceptions
You can catch more than one exception type in a try..catch block. Here I show how.
How to make sure that some code executes whether or not an exception is thrown
You can nest try..catch blocks to handle exceptions that occur in the catch block of an exception handler!
How to handle an exception only when a certain condition is met
Step through your code and watch variables with Visual Studio
You can try out bits of C# code without having to write and compile an entire program using the C# interactive console. Here I show you how to get started with this.
The basics of error-handling and debugging
In the final step we look at collections and dictionaries – then start work on programming a game
The .NET framework supplies strongly-typed ‘generic’ collection classes which comes with lots of useful methods to add, remove and locate objects in the collection.
Dictionaries are lists of values that can be indexed with a ‘key’ rather than a numeric index indication a position in the list.
C# lets you define ‘virtual’ methods that can be ‘overridden’ by methods of the same name in descendant classes.
Let’s see how to use C# classes and techniques to write an exploring game
It may be a text-based game but it needs a graphical user interface!
Where did adventure games come from, anyway?
So how does the player interact with the game?
Now let’s look at the classes in my Adventure Game project.
How can we save and restore all those objects?
Let’s see if how to use a Dictionary instead of a List to store the Room objects of the game.
Subclassed Dictionaries can be serialized. But you need to create a special constructor.
In this step we covered collections and dictionaries. I explained virtual and overridden methods. And finally I provided a reasonably complicated sample project – an adventure game.
Well, that’s it. We’ve come to the end of the course.
Learn C# Programming (in ten easy steps) [Version 2] is suitable for beginner programmers or anyone with experience in another programming language who needs to learn C# from the ground up. Step-by-step it explains how to write C# code to develop Windows applications using either the free Visual Studio Community Edition or a commercial edition of Microsoft Visual Studio. This is the completely revised and updated second version of this course.
C# is one of the most widely used an important of all modern programming languages. If you need to learn C# quickly and painlessly, this is the perfect course.
You will begin by learning the core features of programming – variables, constants, functions and data types. You will move on rapidly to learn about Object Orientation and the more advanced features of C# and the .NET framework such as file-handling, data-streaming, dealing with exceptions (errors) and overriding methods. Even if you start out as a complete beginner, by the end of this course you will have built a really solid foundation of programming knowledge and skills.
All the source code of sample projects is provided ready for you to download, run and modify. The course also includes an eBook that provides even more information on the topics being discussed. And there are also interactive quizzes to test your understanding of each major topic.
The course instructor, Huw Collingbourne, is Director of Technology with SapphireSteel Software, a company that specialises in Visual Studio development tools (written in C#) for professional programmers.
Learn C# Programming (in ten easy steps) is the fastest and simplest way to help you make the move from coding novice to professional programmer. The first version of this course was launched in 2012. The current version has been completely re-made and expanded with numerous new lessons.
As an added bonus, the complete version 1 of the course (almost 4 additional hours of video instruction) is also included as a free download.
There is also an extra bonus project (a drag-and-drop application launchpad) that will help you extend your skills while programming a genuinely useful application.