Where does the .NET C# program start its flow when you build and run a console application?
Experience Level:
Junior
Tags:
C#
Answer
When a user starts a .NET console application, the class Program
is located. Within this class the method Main
is located an the code execution flow starts from there, statement by statement, line by line.
When the application below gets executed, the first command to be executed will be Console.WriteLine("Hello");.
using System;
namespace MyApp {
class Program {
static void Main() {
Console.WriteLine("Hello");
Console.WriteLine("World");
}
}
}
Related C# job interview questions
-
What is a solution in Visual Studio and what file extension does it have?
C# Junior -
What is a difference between .cs file and class?
C# Junior -
What is an object in C#?
C# Junior -
What is a class in C#?
C# Junior -
What are the advantages of using 'using' keyword in C# and why would you use it?
C# Junior