Menu
CoddyTech
Course

C# for Java Developers

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

Java and C# side by side

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

  1. Run Your First C# Program

    Java and C# both compile explicitly declared types and start a main entry point. Java uses public static void main(String[] args); this C# course uses public static void Main(). Namespace and library names differ, and Mono runs the compiled C# program rather…

    Java
    1import java.util.*;2import java.util.function.*;3import java.util.stream.*;4public class Main {5
    6public static void main(String[] args) {7System.out.println("C# is ready");8}9}
    C#
    1Console.WriteLine("C# is ready");
  2. Output, Comments and Main

    Java System.out.println becomes Console.WriteLine. Braces, semicolons and // comments are familiar, but C# member names are case-sensitive and Main is capitalized. A static helper can live in another source file without becoming another entry point.

    Java
    1import java.util.*;2import java.util.function.*;3import java.util.stream.*;4public class Main {5
    6public static void main(String[] args) {7System.out.println("Hi, " + "Mina"); // A comment8}9}
    C#
    1Console.WriteLine("Hi, " + "Mina"); // A comment
  3. Boolean Logic and Equality

    Both Java and C# require boolean conditions and use short-circuit &&/||. Java String == compares references; C# string == normally compares text content. Do not carry Java string-identity assumptions into C# equality checks.

    Java
    1import java.util.*;2import java.util.function.*;3import java.util.stream.*;4public class Main {5
    6public static void main(String[] args) {7boolean active = true;8System.out.println(20 >= 18 && active);9}10}
    C#
    1bool active = true;2Console.WriteLine((20 >= 18 && active) ? "true" : "false");
  4. Arrays and Bounds

    Java arrays and C# arrays are fixed-length reference objects with bounds checks. Java length is lowercase while C# Length is a property. For growth, the common Java choice ArrayList corresponds to List<T>, not a resizable array type.

    Java
    1import java.util.*;2import java.util.function.*;3import java.util.stream.*;4public class Main {5
    6public static void main(String[] args) {7int[] values = {4, 6};8System.out.println(values.length);9}10}
    C#
    1int[] values = { 4, 6 };2Console.WriteLine(values.Length);
  5. Dictionaries and Missing Keys

    Java Map.get returns null for an absent key and getOrDefault offers a fallback. C# Dictionary indexing throws when absent; TryGetValue reports presence through a bool and writes the out value. Choose an explicit ordinal comparer for the C# text-key contract.

    Java
    1import java.util.*;2import java.util.function.*;3import java.util.stream.*;4public class Main {5
    6public static void main(String[] args) {7Map<String,Integer> values = new HashMap<>();8System.out.println(values.getOrDefault("missing", 0));9}10}
    C#
    1var values = new Dictionary<string,int>();2int count;3Console.WriteLine(values.TryGetValue("missing", out count) ? count : 0);
  6. Methods, Defaults and params

    Java varargs corresponds to C# params, but Java has no optional-parameter default syntax and normally uses overloads. C# optional arguments supply declared defaults. Both static helper methods belong to a type rather than an instance.

    Java
    1import java.util.*;2import java.util.function.*;3import java.util.stream.*;4public class Main {5static int total(int factor,int... values) { return Arrays.stream(values).sum()*factor; }6public static void main(String[] args) {7System.out.println(total(3,2,4));8}9}
    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 Java developers

Learn C# from another language

Frequently asked questions

Who is C# for Java Developers for?

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

How many lessons does C# for Java Developers have?

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

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

Get started