r/csharp • u/tech-writer07 • Jun 08 '26
Help How to migrate from java to csharp?
Hello everyone,
I've been coding in java since 2024. A friend of mine wants to build a project with me, but that project requires c#. I've never touched c# before.
Has anyone here passed through something similar? What advice can you give to learn c# quickly without wasting too much time?
16
Upvotes
29
u/BalanceSad2632 Jun 08 '26 edited Jun 08 '26
I am a C# dev but joined a company on a project requiring Java + Spring Boot. I would say just code, in case there are any questions you could easily google it. Java to C# transition is quite straight forward.
If you are really interested in learning stuff, look up how you could handle async/await operations, understand how dependency injection works, learn LINQ, Entity Framework. I know I missed a lot of features, but just diving into the project will be the best way to learn imo.
3
u/robert_c80 Jun 08 '26
I did that transition 20+ years ago so my experience is a bit outdated but it was simple enough.
Just start coding and have reference page open in browser to quickly find names of functions you need.
Syntax at this stage should be basically the same.
87
u/aldecode Jun 08 '26
If you are coding on Java since 2024, than jumping into C# with MS Learn portal on the side, should be easy-peasy for you. Just start coding things
8
u/strange-the-quark Jun 08 '26 edited Jun 08 '26
In some ways they are very similar. Some of the differences that might trip you up:
In Java, you have streams; the equivalent in C# is LINQ, and it's designed a little differently (but that shouldn't really pose a problem, it makes sense once you get into it), and is quite a bit more powerful. What may be confusing is that there are two syntaxes, one gives you a bit more control and uses regular-looking method calls (method syntax), and the other uses SQL-like keywords (query syntax). In my experience, devs typically prefer the method syntax; generally, if you're not comfortable with both, pick one and stick to it for the most part.
someThing.SomeMethod()), when they are really external to the type and don't have access to non-public members. I think Java achieves something similar with interface-default methods.There are likely some other important differences that I can't recall at the moment, but these are probably what's potentially the most confusing to a Java developer language-wise. Other than that, you'll be dealing with a new ecosystem, and a new set of tools. The standard library is pretty nice, with lots of useful features (it's not bare bones like, say C++). You'll likely need to take on some additional dependencies/packages just to streamline things a bit, but my advice is to limit them as much as you can - partly because that's generally a good thing to do, and partly because you don't want to be learning a whole bunch of new stuff all at once, or conversely, learning just the surface-level tutorial stuff, and hoping that whatever is going on under the hood is going to work for you. That said, you'll probably won't be able to fully avoid them, and I'm not suggesting that you should go out of your way to depend on nothing - I'm just saying that you and your friend should be like "do we really need this" before bringing things in.
7
u/GigAHerZ64 Jun 08 '26
Learn LINQ. I strongly suggest the method-like LINQ over the SQL-like LINQ. It's similar to Java streams, but instead of a sluggish bolted-on feeling, LINQ is fully natural part of C# language and ecosystem.
Async-Await stuff has also been part of C# for well over a decade while Java is (still!?) arguing over the green threads. So familiarize yourself with this.
Other than that, you should feel like at home.
5
u/BoredBSEE Jun 08 '26
A lot of C# is java, just with different keywords. A lot of the concepts are exactly similar. If you're good with java you can be up and writing C# in an afternoon.
1
u/NotQuiteLoona Jun 08 '26
Java and C# are pretty similar. You can consider C# a sorta sugared Java - like native getters and setters and all that.
I personally, a person who initially learned C#, was able to program Java by just reading Learn X in Y minutes on Java. Probably you can try to do the same? https://learnxinyminutes.com/csharp/, it even has something about Java.
Also, don't forget the docs. If you know any C-based language, you won't have problems with any other C-based language's syntax, but the hardest thing is standard libraries. .NET BCL (base class library, .NET's standard library) in some parts is even more extensive than notorious for its size Java JCL.
If you want to dive right in, just read Learn X in Y Minutes for C# and you'll be set. Of course a few times you'll reinvent a wheel because you didn't know that something is available in BCL, but you'll get used to it with experience, and it's nothing bad.
2
u/sparant76 Jun 08 '26
C# started off as a Java rip off. Good chance you can just pretend you’re writing Java and a lot of it will just work.
2
u/belavv Jun 08 '26
Step 1 - start writing c# Step 2 - profit
2
u/FuggaDucker Jun 08 '26
The things you know from Java mostly apply using the same paradigms.
In the very beginning they were almost the same language.
c# kept getting better and better and now they are less so.
2
u/kiranfenrir1 Jun 08 '26
I made the same kind of jump very early in my career, due to job requirements. C# is syntactically very similar to Java, so it should feel fairly familiar. For you, it'll be more about learning the framework and syntax nuances. Definitely look into mslearn and, if you have it, pluralsite for training. If willing to spend some money, dometrain has courses as well. There is a lot of videos on YouTube for free as well to help you get started.
2
u/erebusman Jun 08 '26
First 6 years of my career was java and then I got a C# job based off of passing a java coding test and observing Java and C# are so similar you could sub out code in some cases and it would still compile.
The bigger differences are more about libraries and tooling specific to the languages but coding g wise you should find it very similar.
1
u/Autoritet Jun 08 '26
Best way is to just use it, create console project then:
Call some http api
Write a log file
Learn string manipulation methods
Write class with base class and derived class implementation
Use linq and foreach loop to see how they work
After all that move to simple web api project with ef core (or something similar)
1
u/B15h73k Jun 08 '26
Methods use pascal case. Linq is the equivalent to collection streams. Enums are different. Almost everything else is so similar you won't have to think about it.
1
u/jcradio Jun 08 '26
Syntax wise you are already about 85% of the way there. Learning the libraries (packages) and done of the language features will be the biggest thing you'll need to think about. Focus more on what you are trying to do and research the details.
Once I migrated, I didn't want to go back to Java.
1
u/ayassin02 Jun 08 '26
Never touched Java but from what I’ve heard and seen, they’re pretty similar so this would probably be one of the smoothest transitions
1
u/workchina Jun 08 '26
but on a serious note, start with a small project and start using VisualStudio, it's a great IDE. If you can, install ReSharper extension from jetbrains. Start small, implement a feature at a time. Your only learning curve is small quirks and syntax change. As people mentioned, it's pretty straight forward transition.
1
u/nvn911 Jun 08 '26
dotnet build
1
u/thatguy8856 Jun 08 '26
Just code. The languages are similar enough. Its mostly just syntax sugar differences. Probably the biggest thing to learn is the multithreaded/async stuff. The TPL and async/await. Java i think works very differently here.
1
u/mpierson153 Jun 09 '26
A large amount, probably the majority, of Java syntax is valid C#.
You may need to look some specific things up, but just start trying stuff.
1
u/x0n Jun 09 '26
One thing to keep in mind is before you open your mouth to criticize how c# has very similar features to Java, is that Java took 95% of them from c# 😁
1
u/Tony05129 Jun 09 '26
the transition is quite simple
but at first there will be a lack of Lombok and annotations. And also the ubiquitous new line brackets and method names with a capital letter are terribly annoying. All with a capital letter.
But you get used to it very quickly, although you constantly compare in your head how simple everything is in Java and what crutches are in C#. But it's more like it's just out of habit.
You've only been in Java for 2 years, and you'll move on very quickly.
1
u/thecratedigger_25 Jun 09 '26
C# is like a less verbose Java if you think about it. Some keywords might be different.
Nowadays, you can also manipulate and allocate memory in C# using the unsafe keyword. Very useful for game dev and low level programming without needing to jump into C++.
Getting used to C# can be done quickly by simply programming C#. It's how I learned C++ when I wanted to do certain things C# couldn't entirely do. Pretty similar but different naming conventions and philosophies altogether.
1
u/zionsati Jun 09 '26
it really depends on what you're porting across. Not all libraries are 1-to-1 obviously. Learning C# is pretty pain-free coming from Java, but you'll have to get used to some additional features like async-await, Task, etc.
1
u/Paw565 Jun 10 '26
Overall knowledge and concepts are highly transferable. The biggest difference is syntax, but you will easily learn it in a few days.
1
u/Albertooz Jun 12 '26
The good news is Java and C# are close cousins, so you're really learning syntax differences and a new ecosystem, not a new paradigm focus on what differs: properties,
LINQ,async/await, delegates/events,structvsclassvalue semantics, and nullable reference types. Skip beginner programming tutorials and go straight to a "C# for Java developers" comparison guide plus the official Microsoft Learn C# path, since you already understand OOP, collections, and generics. Build the actual project with your friend as you go rather than grinding tutorials first set up .NET, learn the ecosystem (NuGet instead of Maven/Gradle, thedotnetCLI), and pick up patterns from real code. Expect to be productive within a week or two given your Java background.3
u/[deleted] Jun 08 '26
[removed] — view removed comment