C# from the ground up
The language of .NET
- Beginner
- 13 chapters
- 210 min read
Learn C# by running it: printing and arithmetic, variables and the built-in types, interpolated text, decisions with if and switch, loops that repeat and walk collections, your own methods, arrays and lists, dictionaries, classes with properties and constructors, inheritance and interfaces, LINQ as the modern way to ask a collection a question, exceptions, and a spending report that uses the whole course at once.
What You'll Learn
- Write and run a C# program, and say what the entry point is
- Hold values in variables of the right type, and keep money in a decimal
- Build readable lines with interpolation and format specifiers
- Branch with if, else and switch, and combine conditions
- Repeat work with for and while, and walk a collection with foreach
- Write methods with parameters, defaults and return values
- Store many values in an array or a list and walk them
- Look values up by key in a dictionary
- Define classes with properties, constructors and a useful ToString
- Share work with a base class and hold different types behind an interface
- Answer questions about a collection with Where, Select, OrderBy, Sum and Any
- Throw, catch and name the exceptions a program can handle
- Build a grouped spending report with records, LINQ and decimal money
Prerequisites
- No programming experience needed — this course starts at the first line
- Comfort with a text editor and a browser is the whole setup
Course Content
- 01Your first C# programNot started
What C# is for, the entry point every program needs, and Console.WriteLine as the way to make a program say something.
- 02Values, var and the built-in typesNot started
The types C# ships with, what var really means, integer division, and why money is a decimal and never a double.
- 03Text, interpolation and formattingNot started
Building lines from values, the dollar sign that turns a string into a template, format specifiers, and the everyday string methods.
- 04Decisions: if, else and switchNot started
Conditions that are true or false, chains with else if, combinations with and and or, and the switch that picks one branch to run.
- 05Loops: for, while and foreachNot started
Repeating work a counted number of times with for, repeating while a condition holds with while, and walking a collection with foreach.
- 06Methods: a name for a piece of workNot started
Writing your own methods, passing values in, giving a value back, default values for parameters, and the short arrow form.
- 07Arrays and listsNot started
A fixed row of values and a list that grows, indexes that start at nought, and the two everyday ways to walk them.
- 08Dictionaries: looking things up by keyNot started
A collection that answers by name instead of by position, adding and reading pairs, and the check that keeps a missing key from stopping the program.
- 09Classes: properties, constructors and ToStringNot started
Defining your own kind of value, properties that read and write safely, a constructor that runs at creation, and the text an object prints.
- 10Inheritance and interfacesNot started
A base class for what several values share, a derived class for what makes one special, and an interface as a promise one list can hold.
- 11LINQ: asking questions of a collectionNot started
Where, Select and OrderBy as one chain of questions, Sum, Any and Count for the answers, and why the calls read like the sentence you meant.
- 12Exceptions: try, catch and throwNot started
Saying what went wrong with throw, handling what you can with catch, and giving a kind of trouble its own type so the program can tell them apart.
- 13Putting it together: a spending reportNot started
A capstone that uses the whole course once: records for the rows, LINQ to group them by category, and money formatted only on the way out.
