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.
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…
Java1import 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");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.
Java1import 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 commentBoolean 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.
Java1import 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");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.
Java1import 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);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.
Java1import 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);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.
Java1import 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 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 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.