Menu
CoddyTech
Course

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.

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

    Go
    1package main2import ("fmt")3
    4func main() {5fmt.Println("C# is ready")6}
    C#
    1Console.WriteLine("C# is ready");
  2. 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.

    Go
    1package main2import ("fmt")3
    4func main() {5fmt.Println("Hi, " + "Mina") // Greeting6}
    C#
    1Console.WriteLine("Hi, " + "Mina"); // A comment
  3. Boolean 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…

    Go
    1package main2import ("fmt")3
    4func main() {5active := true; fmt.Println(20>=18 && active)6}
    C#
    1bool active = true;2Console.WriteLine((20 >= 18 && active) ? "true" : "false");
  4. 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.

    Go
    1package 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);
  5. 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…

    Go
    1package 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);
  6. 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.

    Go
    1package 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 questions

Start Here

1 lesson

More courses for Go developers

Learn C# from another language

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

Coddy programming languages illustration

Start C# for Go Developers for free

Get started