C# for JavaScript Developers
Use your JavaScript experience to learn C# types, flow, methods, collections and object design. Build and test a multi-file order-processing program with compatible Mono C#.
JavaScript and C# side by side
The same program in JavaScript and in C#, from the lessons of this course.
Run Your First C# Program
JavaScript executes top-level statements and checks many operations only when run. C# compiles explicitly typed classes and methods first, then starts Main. The course uses an older compatible Mono toolchain rather than assuming modern top-level C# syntax.
JavaScript1console.log("C# is ready");C#1Console.WriteLine("C# is ready");Output, Comments and Main
JavaScript console.log becomes Console.WriteLine. C# keeps familiar braces and comments but requires declarations and a program entry point. Return a value from the helper rather than adding a console call that would duplicate the locked driver output.
JavaScript1console.log("Hi, " + "Mina"); // A commentC#1Console.WriteLine("Hi, " + "Mina"); // A commentBoolean Logic and Equality
JavaScript conditions accept truthy and falsy values, and && can return an operand. C# conditions require bool and its boolean && returns bool. Use explicit comparisons or collection counts rather than copying JavaScript truthiness tests.
JavaScript1const active = true;2console.log(20 >= 18 && active);C#1bool active = true;2Console.WriteLine((20 >= 18 && active) ? "true" : "false");Arrays and Bounds
JavaScript arrays resize and missing indexed reads produce undefined. C# arrays have fixed Length and out-of-range reads throw. Use List<T> for growth and check bounds rather than relying on undefined.
JavaScript1const values = [4, 6];2console.log(values.length);C#1int[] values = { 4, 6 };2Console.WriteLine(values.Length);Dictionaries and Missing Keys
JavaScript Map.get returns undefined for absence. C# Dictionary indexing throws, so TryGetValue communicates presence and result separately. A Dictionary key is not an object prototype member, avoiding ordinary JavaScript object-key pitfalls.
JavaScript1const values = new Map();2console.log(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
JavaScript rest parameters correspond to C# params arrays, with statically checked elements. JavaScript defaults also activate for an explicit undefined; C# optional parameters use omission and have no undefined sentinel. Static helper methods belong to a C#…
JavaScript1function total(factor = 2, ...values) { return values.reduce((sum,n) => sum+n,0)*factor; }2console.log(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 JavaScript Developers for?
For people who already write JavaScript and want to learn C#. Each lesson starts from JavaScript 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 JavaScript basics: variables, conditions, loops, functions and collections.
How many lessons does C# for JavaScript Developers have?
C# for JavaScript Developers contains 48 interactive lessons you can complete at your own pace.
What does C# for JavaScript 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 JavaScript Developers free?
Yes. Every course on Coddy is free to start. You can complete lessons in your browser without any downloads or signup.