Learn C# Programming (in ten easy steps) is suitable for beginner programmers. 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 (it even explains how to write C# programs using free tools for OS X). This course is regularly updated and new and revised lessons will appear throughout 2017.
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.
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 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.
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 assign values to variables and constants
How to test conditions and take different actions depending on whether or not they are true. Using if and else, switch and case, testing complex conditions and using operators to test for equality or to test if values are greater than or less than one another.
++, --, +=, -= and more: compound operators, increment and decrement operators and the precedence of operators. This video explains some of the nitty-gritty details of using operators to multiply, divide, add and subtract values.
Methods or functions provide ways of dividing your code into named ‘chunks’. Here we look at how to create methods, define lists of parameters or arguments and use the values returned from methods.
In this video I explain the difference between passing arguments ‘by value’ and ‘by reference’. We also look at the similarities and differences between ‘ref’ and ‘out’ parameters.
How to divide code into named blocks
What exactly is Object Orientation and why does it matter? In this lesson we explain what objects and classes are and how objects can automatically inherit the features of their ancestors.
In this 'hands on' lesson, I’ll guide you through the process of writing a simple class definition and creating an object from it.
In this lesson you’ll learn how to create a descendants of en existing class, call the ancestor class’s constructor and use properties to get and set the values of an object’s variables.
How to create and use objects
Arrays are sequential lists of items. Here I explain what an array is, how to create arrays of standard data types or custom objects and how to iterate through the items in an array using various types of loops.
In some ways a string is a bit like an array. It can be treated as a sequential list of characters and you can loop through those characters much as you would loop through array items. Here I also show how to create a simple text editor and a word counter.
Sequential lists of characters and other data types
Here we look at the fundamentals of file handling. How to verify that files exist, how to move or copy files and make use of the File, Directory, Path and Environment classes. We also look at static methods.
The .NET framework provides various Stream classes to simplify the process of reading and writing text and binary files. This lesson gives an overview of some of the most important Stream and Stream-handling classes.
Handling input and output in C#
Here we look at some additional features of classes and methods such as partial and static classes and methods with the same names but different arguments
A struct is like a class without inheritance and an Enum is like a categorised set of constants. You may not need to use them in your own programs but you will need to understand them as they occur throughout .NET.
Structures and enumerated constants
Exceptions are error objects. They come in different varieties and they can crash your programs unless you ‘catch’ them. Here we look at the fundamentals of exception handling in C#.
Use the Visual Studio Debugger to pause the execution of your program at ‘breakpoints’. Then step through your code from one line to another and examine variables to see how their values change as the program runs.
Finding and fixing errors
The .NET framework supplies strongly-typed ‘generic’ collection classes such as List and Dictionary which come with lots of useful methods to add, remove and locate objects in a collection. This lesson gives an overview of generic collections.
C# lets you define ‘virtual’ methods that can be ‘overridden’ by methods of the same name in descendant classes. Here we look at the syntax of overridden methods and consider why they may be useful.
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 wit this.
In the code archive for this step you will find a project that implements a simple exploring-style ‘text adventure’ game. This game illustrates many of the techniques we’ve discussed in the course. In this lesson I’ll guide you through the game and provide some idea for ways in which you can use it to carry on learning more about C#.
Huw Collingbourne is the technology director at SapphireSteel Software, developers of programming tools for Microsoft Visual Studio. He is author of The Book Of Ruby from No Starch Press. He runs Bitwise Courses and teaches courses on a range of programming topics.
Huw has been a programmer for more than 30 years. He is a well-known technology writer in the UK. For over ten years he wrote the Delphi and Java programming column for PC Plus Magazine. He has also written numerous opinion and programming columns (including tutorials on C#, C++, Smalltalk and Ruby) for a number of computer magazines, such as Computer Shopper, PC Pro, and PC Plus.
In the 1980s he was a pop music journalist and interviewed most of the New Romantic stars, such as Duran Duran, Spandau Ballet, Adam Ant, Boy George, and Depeche Mode. He is now writing a series of New Romantic murder mysteries.
At various times Huw has been a magazine publisher, editor, and TV broadcaster. He has an MA in English from the University of Cambridge and holds a 2nd dan black belt in aikido, a martial art which he teaches in North Devon, UK. The aikido comes in useful when trying (usually unsuccessfully) to keep his Pyrenean Mountain Dogs under some semblance of control.