Kotlin for C# Developers
Transfer C# experience to Kotlin through null safety, collections, functions, properties and object contracts. Build a connected multi-file order processor and port a stock ledger.
C# and Kotlin side by side
The same program in C# and in Kotlin, from the lessons of this course.
Strings and Templates
C# interpolated strings place a dollar prefix before the quote. Kotlin templates use dollar markers inside an ordinary quoted string, and braced expressions handle more complex substitutions. Kotlin allows a top-level main function; the JVM compiler supplies…
C#1using System;2using System.Collections.Generic;3using System.Linq;4using System.Globalization;5class Program {6 7static void Main(){8int ready=3;Console.WriteLine($"Ready: {ready}");9}10}Kotlin1 2fun main(){3val ready=34println("Ready: $ready")5}Equality and Identity
C# string equality operators compare contents, and Kotlin string == also uses structural equality. C# can overload equality operators for other types; Kotlin == follows equals rather than importing arbitrary C# operator declarations. Kotlin === tests…
C#1using System;2using System.Collections.Generic;3using System.Linq;4using System.Globalization;5class Program {6 7static void Main(){8string a=new string(new[]{'t','e','a'}),b=new string(new[]{'t','e','a'});Console.WriteLine(a==b);9}10}Kotlin1 2fun main(){3val a=String(charArrayOf('t','e','a'))4val b=String(charArrayOf('t','e','a'))5println(a==b)6}Arrays and IntArray
C# and Kotlin arrays both have fixed lengths and mutable element slots. Kotlin IntArray supplies primitive integer storage, whereas Array<Int> is a generic array representation. C# Length becomes Kotlin size, and last or lastIndex can express end access.…
C#1using System;2using System.Collections.Generic;3using System.Linq;4using System.Globalization;5class Program {6 7static void Main(){8int[]values={4,8,12};Console.WriteLine(values[values.Length-1]);9}10}Kotlin1 2fun main(){3val a=intArrayOf(4,8,12)4println(a.last())5}While, Break, and Continue
C# and Kotlin share break and continue as separate loop-control operations. Kotlin also offers labeled jumps for intentional outer-loop control. Ensure a while loop can make progress on every continuing path. The word demonstration skips an empty item and…
C#1using System;2using System.Collections.Generic;3using System.Linq;4using System.Globalization;5class Program {6 7static void Main(){8var kept=new List<string>();foreach(string word in new[]{"tea","","STOP","coffee"}){if(word=="STOP")break;if(word.Length==0)continue;kept.Add(word);}Console.WriteLine(String.Join(",",kept));9}10}Kotlin1 2fun main(){3val kept=mutableListOf<String>()4for(word in listOf("tea","","STOP","coffee")){if(word=="STOP")break;if(word.isEmpty())continue;kept.add(word)}5println(kept.joinToString(","))6}Top-level Functions
C# methods commonly belong to a class and may use ref or out to rebind caller variables. Kotlin supports top-level functions, and ordinary parameters do not provide C# ref/out rebinding. Return a value or a dedicated result model when moving such an API.…
C#1using System;2using System.Collections.Generic;3using System.Linq;4using System.Globalization;5class Program {6static bool IsLong(string text){return text.Length>4;}7static void Main(){8Console.WriteLine(IsLong("coffee"));9}10}Kotlin1fun isLong(text:String):Boolean = text.length>42fun main(){3println(isLong("coffee"))4}Input and String Formatting
C# string trimming and invariant case conversion have Kotlin counterparts, with JVM locale-aware operations available when needed. Input contracts determine whether whitespace is meaningful. Kotlin readlnOrNull distinguishes end-of-input, and the locked…
C#1using System;2using System.Collections.Generic;3using System.Linq;4using System.Globalization;5class Program {6 7static void Main(){8Console.WriteLine(" tea ".Trim().ToUpperInvariant());9}10}Kotlin1 2fun main(){3println(" tea ".trim().uppercase(java.util.Locale.ROOT))4}
Syllabus
10 chapters48 lessons1 project48 challenges99 quiz questionsStarting Kotlin
6 lessonsValues and Decisions
5 lessonsCollections and Ownership
5 lessonsIteration and Transformations
5 lessonsFunctions and Callbacks
5 lessonsInput, Errors, and Files
5 lessonsClasses and State
6 lessonsComposition and Value Types
5 lessonsProject: Order Processing
4 lessonsFinal Challenges
2 lessonsFrequently asked questions
Who is Kotlin for C# Developers for?
For people who already write C# and want to learn Kotlin. Each lesson starts from C# you know and shows how Kotlin does the same thing, so you skip the beginner basics.
Do I need to know Kotlin already?
No. The course starts with your first Kotlin program. You need C# basics: variables, conditions, loops, functions and collections.
How many lessons does Kotlin for C# Developers have?
Kotlin for C# Developers contains 48 interactive lessons you can complete at your own pace.
What does Kotlin for C# Developers cover?
The course is organized into chapters covering: Starting Kotlin, Values and Decisions, Collections and Ownership, Iteration and Transformations, and more.
Is Kotlin for C# Developers free?
Yes. Every course on Coddy is free to start. You can complete lessons in your browser without any downloads or signup.