C# for Swift Developers
Use your Swift experience to learn C# types, flow, methods, collections and object design. Build and test a multi-file order-processing program with compatible Mono C#.
Swift and C# side by side
The same program in Swift and in C#, from the lessons of this course.
Run Your First C# Program
A Swift executable can use top-level statements in main.swift. This C# runner starts a static Main method on a class and compiles sibling .cs files together. Swift source references run separately; the challenge editor runs Mono C#.
Swift1import Foundation2 3print("C# is ready")C#1Console.WriteLine("C# is ready");Output, Comments and Main
Swift print and C# Console.WriteLine append a newline. Both support // comments and brace blocks, but C# requires statement semicolons. Put ordinary C# helper methods on a type rather than using top-level Swift-style declarations.
Swift1import Foundation2 3print("Hi, " + "Mina") // GreetingC#1Console.WriteLine("Hi, " + "Mina"); // A commentBoolean Logic and Equality
Swift and C# require Bool/bool conditions and use &&, || and !. Swift Equatable enables value equality; C# ordinary class == starts as identity comparison unless overloaded. Swift === applies to classes; C# ReferenceEquals states identity explicitly.
Swift1import Foundation2 3let active=true4print(20>=18 && active)C#1bool active = true;2Console.WriteLine((20 >= 18 && active) ? "true" : "false");Arrays and Bounds
Swift Array has value semantics with copy-on-write optimization; assignment behaves as an independent value. C# arrays are fixed-length reference objects and assignment aliases. Clone explicitly to preserve a C# caller array, and use List<T> when growth is…
Swift1import Foundation2 3let values=[4,6]4var copy=values5copy[0]=96print("\(values[0]):\(copy[0])")C#1int[] values = { 4, 6 };2Console.WriteLine(values.Length);Dictionaries and Missing Keys
Swift dictionary subscripting normally returns an Optional and its default subscript can supply a fallback. C# Dictionary indexers throw for absence. TryGetValue separates presence from value, especially when a stored zero is meaningful.
Swift1import Foundation2 3let counts:[String:Int]=[:]4print(counts["missing",default:0])C#1var values = new Dictionary<string,int>();2int count;3Console.WriteLine(values.TryGetValue("missing", out count) ? count : 0);Methods, Defaults and params
Swift default arguments and variadic parameters have similar C# optional/params roles. Swift argument labels are part of call design; C# named arguments refer to parameter names with a colon. C# params also accepts an existing array directly.
Swift1import Foundation2func total(_ factor:Int=2,_ values:Int...)->Int{values.reduce(0,+)*factor}3print(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 Swift Developers for?
For people who already write Swift and want to learn C#. Each lesson starts from Swift 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 Swift basics: variables, conditions, loops, functions and collections.
How many lessons does C# for Swift Developers have?
C# for Swift Developers contains 48 interactive lessons you can complete at your own pace.
What does C# for Swift 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 Swift Developers free?
Yes. Every course on Coddy is free to start. You can complete lessons in your browser without any downloads or signup.