C# for Python Developers
Use your Python experience to learn C# types, flow, methods, collections and object design. Build and test a multi-file order-processing program with compatible Mono C#.
Python and C# side by side
The same program in Python and in C#, from the lessons of this course.
Run Your First C# Program
Python executes statements directly. C# first compiles declared classes and methods, then starts Main. These examples compare behavior; the challenge editor runs C#, not Python.
Python1print("C# is ready")C#1Console.WriteLine("C# is ready");Output, Comments and Main
Python print becomes Console.WriteLine. Python # comments become // comments. Indentation groups Python statements, but braces define C# blocks and semicolons terminate statements. Helper methods can return strings without printing them.
Python1print("Hi, " + "Mina") # A commentC#1Console.WriteLine("Hi, " + "Mina"); // A commentBoolean Logic and Equality
Python permits truthiness of numbers and collections and uses and/or/not. C# conditions require bool and use &&/||/!. A Python empty list condition cannot be copied into C# without an explicit count check.
Python1active = True2print("true" if 20 >= 18 and active else "false")C#1bool active = true;2Console.WriteLine((20 >= 18 && active) ? "true" : "false");Arrays and Bounds
Python lists resize and allow negative indexing. C# arrays have fixed length and negative indices are invalid. Both reject ordinary out-of-range reads, but the exception types differ. Use List<T> when the C# collection needs to grow.
Python1values = [4, 6]2print(len(values))C#1int[] values = { 4, 6 };2Console.WriteLine(values.Length);Dictionaries and Missing Keys
Python dict.get provides a default on absence. C# TryGetValue separates the presence bool from the out value, while its indexer throws on a missing key like Python indexing. Explicit ordinal comparison avoids locale-dependent assumptions about string keys.
Python1values = {}2print(values.get("missing", 0))C#1var values = new Dictionary<string,int>();2int count;3Console.WriteLine(values.TryGetValue("missing", out count) ? count : 0);Methods, Defaults and params
Python *args corresponds to a C# params array. C# optional arguments are constrained by the declared types; Python-style unrestricted argument mixtures are not implied. Static C# helper methods live on a type, while Python module functions need no enclosing…
Python1def total(factor=2, *values):2 return sum(values) * factor3print(total(3, 2, 4))C#1static string JoinTags(string prefix = "tags", params string[] tags) { return prefix + ":" + string.Join(",", tags); }
Syllabus
11 chapters48 lessons1 project48 challenges99 quiz questionsStart Here
1 lessonC# Values and Text
6 lessonsDecisions and Missing Values
5 lessonsLoops and Sequences
5 lessonsCollections and Queries
5 lessonsMethods and Callbacks
5 lessonsReliable C# Modules
5 lessonsClasses and Encapsulation
5 lessonsPolymorphism and Equality
5 lessonsProject: Order Pipeline
4 lessonsFinal Challenges
2 lessonsFrequently asked questions
Who is C# for Python Developers for?
For people who already write Python and want to learn C#. Each lesson starts from Python you know and shows how C# does the same thing, so you skip the beginner basics.
Do I need to know C# already?
No. The course starts with your first C# program. You need Python basics: variables, conditions, loops, functions and collections.
How many lessons does C# for Python Developers have?
C# for Python Developers contains 48 interactive lessons you can complete at your own pace.
What does C# for Python Developers cover?
The course is organized into chapters covering: Start Here, C# Values and Text, Decisions and Missing Values, Loops and Sequences, and more.
Is C# for Python Developers free?
Yes. Every course on Coddy is free to start. You can complete lessons in your browser without any downloads or signup.