6

Can I apply my Java knowledge to C#?

 3 years ago
source link: https://dev.to/baenencalin/can-i-apply-my-java-knowledge-to-c-3b9l
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Can I apply my Java knowledge to C#?

Jan 2

・1 min read

I was just wondering what about Java can and can not be applied to C#.
I know they have a lot of similarities, but what are some of the key differences, and what are the "key similarities"?

Also, one question I definitely want answered is: "I learned how to compile C# using csc test.cs, but, how is the main class chosen?".

Discussion

Subscribe

pic

CollapseExpand

Java and C# unfortunately have less and less common over the years. Nowadays they differ in almost everything. The only principles you can apply in C# you already know are not Java specific - like inheritance, polymorphism, inversion of control, interfaces, etc.
From my own experience writing applications in C# is far less code and more syntactic sugar than Java.
.Net framework has most of the stuff you need and if you need something more it's most of the time provided as NuGet packages by Microsoft while NuGet package management is part of the framework. No more messing with Maven, Nexus and 5 different Java packages for a simple requirement.
The best starting point would be. Net Core framework, which has CLI tool dotnet that allows you to bootstrap a C# project or solution in a second.
By default C# program is searching for void Main() method and executes it first but this may differ for different project types (class library vs. console program vs. web application).
It is advised you create new project using dotnet new command which creates project_name.csproj file which eases running it by using dotnet run command.
If you already have built .dll file you can use dotnet path/to/the/file.dll any arguments to run it.

Comment button Reply

CollapseExpand

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK