Menu
CoddyTech
Course

Luau for C# Developers

Transfer C# collections, delegates and classes to Luau tables, closures and typed signatures. Practice runtime validation, relative modules and metatable objects, build a stock ledger and port two C# programs.

C# and Luau side by side

The same program in C# and in Luau, from the lessons of this course.

  1. Print and Comment

    C# Console.WriteLine supports interpolation and overloads. Luau print converts values and inserts tabs between arguments. Join one string with .. or string.format when exact spacing matters. Luau chunks execute directly without a class or entry-point…

    C#
    1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text.RegularExpressions;5Console.WriteLine("Hi" + ", Ada");
    Luau
    1local name = "Ada"2print(`Hi, {name}`)
  2. Missing Fields and Optionals

    A C# dictionary can retain a key with a null value; ContainsKey distinguishes that entry from absence. Luau nil removes a table association. A number? annotation describes number or nil but cannot preserve a present-without-value entry. Use a tagged record or…

    C#
    1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text.RegularExpressions;5var record=new Dictionary<string,object>{{"x",null}}; Console.WriteLine(record.ContainsKey("x"));
    Luau
    1local d = {x = nil}2print(d.x == nil)
  3. Inclusive Numeric Loops

    C# counted loops commonly use an exclusive upper bound. Luau numeric for includes its final bound and accepts an optional step. Translate the sequence of visited values, including descending and empty-input cases. Reusing an exclusive bound unchanged can…

    C#
    1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text.RegularExpressions;5int total=0; for(int i=1;i<4;i++) total+=i; Console.WriteLine(total);
    Luau
    1local total = 02for i = 1, 3 do total = total + i end3print(total)
  4. Functions and Returns

    C# signatures check parameter types and distinguish value arguments from ref or out parameters. Luau annotations describe static expectations but are not enforced by this runner’s analyzer. Numeric rebinding stays local; table fields can mutate shared state.…

    C#
    1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text.RegularExpressions;5static int Twice(int x)=>x*2; Console.WriteLine(Twice(4));
    Luau
    1local function twice(x: number): number return x * 2 end2print(twice(4))
  5. Lists as Dense Tables

    C# arrays have fixed length while List<T> supports insertion and removal. Luau uses dense one-based tables for sequences, with table.remove shifting later elements. Setting a slot to nil creates a hole. Sequence length rules should not be used to count…

    C#
    1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text.RegularExpressions;5var values=new List<string>{"a","b","c"}; values.RemoveAt(1); Console.WriteLine(string.Join(",",values));
    Luau
    1local a = {"a", "b", "c"}2table.remove(a, 2)3print(table.concat(a, ","))
  6. Sorting and Comparators

    C# sorting comparers normally return a negative, zero or positive integer. Luau table.sort expects a Boolean strict-order predicate and mutates the sequence. A numeric difference is wrong because even zero is truthy. Keep the original table reference rather…

    C#
    1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text.RegularExpressions;5var values=new List<int>{3,1,2}; values.Sort((a,b)=>a.CompareTo(b)); Console.WriteLine(values[0]);
    Luau
    1local a={3,1,2}2table.sort(a)3print(a[1])

Syllabus

10 chapters48 lessons1 project48 challenges99 quiz questions

Final Source Ports

2 lessons

More courses for C# developers

Learn Luau from another language

Frequently asked questions

Who is Luau for C# Developers for?

For people who already write C# and want to learn Luau. Each lesson starts from C# you know and shows how Luau does the same thing, so you skip the beginner basics.

Do I need to know Luau already?

No. The course starts with your first Luau program. You need C# basics: variables, conditions, loops, functions and collections.

How many lessons does Luau for C# Developers have?

Luau for C# Developers contains 48 interactive lessons you can complete at your own pace.

What does Luau for C# Developers cover?

The course is organized into chapters covering: First Luau Programs, Values and Decisions, Iteration and Flow, Functions and Closures, and more.

Is Luau 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.

Coddy programming languages illustration

Start Luau for C# Developers for free

Get started