Menu
CoddyTech
Course

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.

  1. 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#.

    Swift
    1import Foundation2
    3print("C# is ready")
    C#
    1Console.WriteLine("C# is ready");
  2. 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.

    Swift
    1import Foundation2
    3print("Hi, " + "Mina") // Greeting
    C#
    1Console.WriteLine("Hi, " + "Mina"); // A comment
  3. Boolean 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.

    Swift
    1import Foundation2
    3let active=true4print(20>=18 && active)
    C#
    1bool active = true;2Console.WriteLine((20 >= 18 && active) ? "true" : "false");
  4. 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…

    Swift
    1import Foundation2
    3let values=[4,6]4var copy=values5copy[0]=96print("\(values[0]):\(copy[0])")
    C#
    1int[] values = { 4, 6 };2Console.WriteLine(values.Length);
  5. 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.

    Swift
    1import 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);
  6. 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.

    Swift
    1import 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 questions

Start Here

1 lesson

More courses for Swift developers

Learn C# from another language

Frequently 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.

Coddy programming languages illustration

Start C# for Swift Developers for free

Get started