Introduction to dotnet with a simple hello world example

dotnet_intro

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

Overview_of_the_Common_Language_Infrastructure_2015.svg.png

Where can dotnet run

  • dotnet can run on multiple operating systems like windows, linux based systems, android, macOS

image.png

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

image.png

image.png

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

image.png

  • 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

image.png

image.png

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.

image.png

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 a bin 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

image.png

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

Comments

Popular posts from this blog

ClaimsPrincipal, ClaimsIdentity, Claims explained in dotnet authentication

Implicit usings, top level statements, file scoped namespaces in dotnet