M
M
Mishka_Sev2020-09-12 00:10:33
ASP.NET
Mishka_Sev, 2020-09-12 00:10:33

Where is the entry point in C# used?

I started to study programming, before that I did not learn anything except pure C.
The first thing I saw in Blazor is a file called Entry Point

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;

namespace BlazorApp
{
    public class Program
    {
        public static void Main(string[] args)
        {
            CreateHostBuilder(args).Build().Run();
        }

        public static IHostBuilder CreateHostBuilder(string[] args) =>
            Host.CreateDefaultBuilder(args)
                .ConfigureWebHostDefaults(webBuilder =>
                {
                    webBuilder.UseStartup<Startup>();
                });
    }
}

The very first thing I came across, and what I did not understand, was this file, its purpose. I take it this is the beginning?
What does this file do, and where / by whom / what is it used, can someone comment out blocks, lines?
using- as I understand it, how in C the directive for the Inсlude preprocessor is only called differently?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vasily Bannikov, 2020-09-12
@Mishka_Sev

Detailed explanation from the documentation
Briefly:
using- kind of Include, but not really.
namespace- just what using adds to the current file (otherwise you would have to write full names like Microsoft.Extensions.Hosting.IHostBuilder). I think you can consider it (namespace) as an analogue of a folder
public class Program- declaring a public class (only because in C # you can’t immediately start writing code without declaring the Main method, and a method cannot be declared without a class - in C # 9 it will be possible, but it doesn’t matter)
public static void Main(string[] args)- An analogue from the sishny void main(int argc, char* argv[])
Since you have such questions, it’s too early for you to climb into Blazor

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question