C# for Go Developers
Use your Go experience to learn C# types, flow, methods, collections and object design. Build and test a multi-file order-processing program with compatible Mono C#.
Go and C# side by side
The same program in Go and in C#, from the lessons of this course.
Run Your First C# Program
Go starts main in package main. This C# runner compiles sibling .cs files and starts static Main on a class. Go packages organize compilation and imports; a C# namespace is a naming scope rather than a Go package.
Go1package main2import ("fmt")3 4func main() {5fmt.Println("C# is ready")6}C#1Console.WriteLine("C# is ready");Output, Comments and Main
Go fmt.Println maps to C# Console.WriteLine for a single formatted value. Both use // comments. C# requires semicolons and braces around method bodies; Go normally inserts semicolons automatically.
Go1package main2import ("fmt")3 4func main() {5fmt.Println("Hi, " + "Mina") // Greeting6}C#1Console.WriteLine("Hi, " + "Mina"); // A commentBoolean Logic and Equality
Go and C# conditions require bool and use &&, || and !. C# equality availability differs from Go comparability: Go slices and maps cannot be compared to one another with ==. C# collections normally use reference equality unless an explicit content contract is…
Go1package main2import ("fmt")3 4func main() {5active := true; fmt.Println(20>=18 && active)6}C#1bool active = true;2Console.WriteLine((20 >= 18 && active) ? "true" : "false");Arrays and Bounds
Go arrays are fixed-size values and assignment copies the array. C# arrays are fixed-size reference objects, so assignment aliases. Go slices are views over backing arrays; C# List<T> is a growable container with different capacity and sharing rules.
Go1package main2import ("fmt")3 4func main() {5values:=[2]int{4,6}; copy:=values; copy[0]=9; fmt.Printf("%d:%d\n",values[0],copy[0])6}C#1int[] values = { 4, 6 };2Console.WriteLine(values.Length);Dictionaries and Missing Keys
Go map lookup yields the zero value for absence, and comma-ok distinguishes an absent key from stored zero. C# Dictionary indexers throw for absence; TryGetValue is the matching presence-plus-value pattern. Initialize a Go map before writes; C# likewise needs…
Go1package main2import ("fmt")3 4func main() {5counts:=map[string]int{};n,found:=counts["missing"];fmt.Printf("%d:%t\n",n,found)6}C#1var values = new Dictionary<string,int>();2int count;3Console.WriteLine(values.TryGetValue("missing", out count) ? count : 0);Methods, Defaults and params
Go variadic parameters correspond to C# params arrays. Go has no default arguments or named argument calls; C# optional parameters introduce those additional call forms. A Go slice expands with ..., while C# accepts an array directly for params.
Go1package main2import ("fmt")3func total(factor int,values ...int) int {sum:=0;for _,n:=range values {sum+=n};return sum*factor}4func main() {5fmt.Println(total(3,2,4))6}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 Go Developers for?
For people who already write Go and want to learn C#. Each lesson starts from Go 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 Go basics: variables, conditions, loops, functions and collections.
How many lessons does C# for Go Developers have?
C# for Go Developers contains 48 interactive lessons you can complete at your own pace.
What does C# for Go 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 Go Developers free?
Yes. Every course on Coddy is free to start. You can complete lessons in your browser without any downloads or signup.