C# for Kotlin Developers
Use your Kotlin experience to learn C# types, flow, methods, collections and object design. Build and test a multi-file order-processing program with compatible Mono C#.
Kotlin and C# side by side
The same program in Kotlin and in C#, from the lessons of this course.
Run Your First C# Program
Kotlin permits a top-level main function. This C# runner requires static Main inside a class and compiles all sibling .cs files together. The source references run on Kotlin/JVM; editable challenges run on Mono C#.
Kotlin1 2fun main() {3println("C# is ready")4}C#1Console.WriteLine("C# is ready");Output, Comments and Main
Kotlin println maps to C# Console.WriteLine and // comments transfer directly. C# requires semicolons after statements. Kotlin top-level functions become static methods on a C# type in this compiler environment.
Kotlin1 2fun main() {3println("Hi, " + "Mina") // Greeting4}C#1Console.WriteLine("Hi, " + "Mina"); // A commentBoolean Logic and Equality
Both Kotlin and C# require Boolean/bool conditions and share &&, || and !. Kotlin == generally invokes structural equality and === checks identity. C# == for ordinary classes defaults to reference comparison unless overloaded; choose Equals for an explicit…
Kotlin1 2fun main() {3val active=true4println(20>=18 && active)5}C#1bool active = true;2Console.WriteLine((20 >= 18 && active) ? "true" : "false");Arrays and Bounds
Kotlin IntArray and C# int[] are fixed-length reference objects; assignment aliases them. Kotlin Array<Int> boxes differently from IntArray on JVM. C# List<int> supplies growth when a fixed array is unsuitable.
Kotlin1 2fun main() {3val values=intArrayOf(4,6)4val alias=values5alias[0]=96println(values[0])7}C#1int[] values = { 4, 6 };2Console.WriteLine(values.Length);Dictionaries and Missing Keys
Kotlin map lookup returns a nullable value and Elvis can provide a default. C# Dictionary indexers throw on absence; TryGetValue is the safe presence test. Kotlin containsKey is needed to distinguish absence from a stored null in nullable maps.
Kotlin1 2fun main() {3val counts=mutableMapOf<String,Int>()4println(counts["missing"] ?: 0)5}C#1var values = new Dictionary<string,int>();2int count;3Console.WriteLine(values.TryGetValue("missing", out count) ? count : 0);Methods, Defaults and params
Kotlin default parameters and vararg have close C# counterparts in optional parameters and params. Kotlin uses a spread operator to pass an existing array to vararg; C# accepts an array directly. Named arguments use = in Kotlin and : in C#.
Kotlin1fun total(factor:Int=2,vararg values:Int)=values.sum()*factor2fun main() {3println(total(3,2,4))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 Kotlin Developers for?
For people who already write Kotlin and want to learn C#. Each lesson starts from Kotlin 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 Kotlin basics: variables, conditions, loops, functions and collections.
How many lessons does C# for Kotlin Developers have?
C# for Kotlin Developers contains 48 interactive lessons you can complete at your own pace.
What does C# for Kotlin 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 Kotlin Developers free?
Yes. Every course on Coddy is free to start. You can complete lessons in your browser without any downloads or signup.