Introduction to dotnet with a simple hello world example
Introduction to dotnet with a simple hello world example
What is dotnet
- Dotnet is an ecosystem or a framework that consists of languages, runtime (CLR), common language infrastructure (CLI), base class libraries (BCL)
- CLR is like JVM for Java applications
Where can dotnet run
- dotnet can run on multiple operating systems like windows, linux based systems, android, macOS
Why use Dotnet
- Using Dotnet, we can create secure, cross-platform, enterprise grade, high performance, maintainable, reusable, testable, easily hostable web applications
- We can exploit the rich open source .NET ecosystem that has been around for decades and still actively maintained by community and Microsoft
- .NET uses C# language which is best for creating readable and maintainable code. C# is evolving faster to become more powerful due to open source community thereby increasing the developer friendliness and productivity
Common Dotnet Frameworks
Dotnet has frameworks to create applications for common use cases like web apps, desktop etc. as follows
Use case | Dotnet Framework |
---|---|
Websites | Web forms, Razor pages, Blazor |
Desktop apps | WPF, Winforms, MAUI |
Mobile apps | Xamarin, MAUI |
Games | Unity |
Dotnet application development
- Dotnet applications can be developed by installing dotnet SDK
- IDEs like Visual Studio and VS code (along with c# dev kit extension) provide syntax highlighting, convenient UI to manage packages, build, run and debug dotnet applications during development
Dotnet packages
- Just like npm (for node js), Maven (for Java), pip (for python), many opensource community build packages can be downloaded and used in a Dotnet project using Nuget package manager.
Simple dotnet hello world application
- Create a folder named helloworld. Open a command line in the folder.
- Create a new console project using the command
dotnet new console
- Build the project using the command
dotnet build
. This compiles the c# code and creates abin
folder which contains the CIL (Common Intermediate Language) code of the application as a dll file. An exe file is also created in the bin folder. Running the exe file makes dotnet runtime to run the dll file that contains the CIL code. - run the project using the command
dotnet run
Projects and Solutions in dotnet
- Project is a C# application. It is defined by a .csproj file
- Solution is a collection of multiple projects. It is defined using a .sln file
- A simple C# solution folder structure can be as follows
ConsoleAppSolution
│ ConsoleAppSolution.sln
│
├───ConsoleApp1
│ ConsoleApp1.csproj
│ Program.cs
│
└───ConsoleApp2
ConsoleApp2.csproj
Program.cs
Video
The video tutorial for this post can be found here
References
- Dotnet docs - https://learn.microsoft.com/en-us/dotnet/
- Download dotnet sdk - https://dotnet.microsoft.com/en-us/download)
- Wikipedia - https://en.m.wikipedia.org/wiki/.NET
Comments
Post a Comment