Menu
CoddyTech
Course

C# for Luau Developers

Use your Luau experience to learn C# types, flow, methods, collections and object design. Build and test a multi-file order-processing program with compatible Mono C#.

Luau and C# side by side

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

  1. Run Your First C# Program

    Luau runs a script from top to bottom with no Main, values carry their types at runtime, and type annotations are optional hints that the Luau analyzer checks apart from execution. C# compiles into a different runtime model with declared value/reference types…

    Luau
    1print("C# is ready")
    C#
    1Console.WriteLine("C# is ready");
  2. Output, Comments and Main

    Luau print writes its arguments and a newline, -- starts a comment, and words such as then, do and end close blocks. This C# environment uses Console.WriteLine inside a static Main and separate checked helper classes. Strings join with + instead of .., and //…

    Luau
    1print("Hi, " .. "Mina") -- A comment
    C#
    1Console.WriteLine("Hi, " + "Mina"); // A comment
  3. Boolean Logic and Equality

    Luau treats only nil and false as falsy, so 0 and an empty string count as true, and and/or return one of their operands rather than a boolean. C# conditions require bool, so a number or string cannot stand in without a comparison. Luau's and, or, not and ~=…

    Luau
    1local active: boolean = true2print(20 >= 18 and active)
    C#
    1bool active = true;2Console.WriteLine((20 >= 18 && active) ? "true" : "false");
  4. Arrays and Bounds

    A Luau table used as an array starts at index 1, grows with table.insert, and returns nil for an index past its end instead of failing. C# arrays start at index 0, have a fixed Length, and indexed access throws outside it. Use List<T> for C# growth and…

    Luau
    1local values: {number} = {4, 6}2print(#values)
    C#
    1int[] values = { 4, 6 };2Console.WriteLine(values.Length);
  5. Dictionaries and Missing Keys

    Indexing a Luau table with a missing key returns nil, so values[key] or 0 is the usual fallback. C# Dictionary indexing throws on an absent key and TryGetValue reports presence with an out result. A Luau table cannot hold nil as a value, while a C# dictionary…

    Luau
    1local values: {[string]: number} = {}2print(values["missing"] or 0)
    C#
    1var values = new Dictionary<string,int>();2int count;3Console.WriteLine(values.TryGetValue("missing", out count) ? count : 0);
  6. Methods, Defaults and params

    Luau has no default parameter syntax: a missing argument arrives as nil and the function writes factor or 2 itself, and ... collects extra arguments. C# declares optional values in the signature and gathers trailing arguments with params. C# methods live on…

    Luau
    1local function total(factor: number?, ...: number): number2	local f = factor or 23	local sum = 04	for _, n in ipairs({...}) do5		sum += n6	end7	return sum * f8end9print(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 Luau developers

Learn C# from another language

Frequently asked questions

Who is C# for Luau Developers for?

For people who already write Luau and want to learn C#. Each lesson starts from Luau 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 Luau basics: variables, conditions, loops, functions and collections.

How many lessons does C# for Luau Developers have?

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

What does C# for Luau 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 Luau 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 Luau Developers for free

Get started