I study C #, and he says in the tutorial, “When you run your program, C # looks for the Main method. It uses the main method as a starting point for your programs. Then it runs any code between the two curly braces.”
But another training site has a code snippet that says
using System;
namespace RectangleApplication
{
class Rectangle
{
double length;
double width;
public void Acceptdetails()
{
length = 4.5;
width = 3.5;
}
public double GetArea()
{
return length * width;
}
public void Display()
{
Console.WriteLine("Length: {0}", length);
Console.WriteLine("Width: {0}", width);
Console.WriteLine("Area: {0}", GetArea());
}
}
class ExecuteRectangle
{
static void Main(string[] args)
{
Rectangle r = new Rectangle();
r.Acceptdetails();
r.Display();
Console.ReadLine();
}
}
}
Using the Main method below other methods. (I am new to this, so I assume that public void acceptdetails, get scope, mapping, all methods). My question is: why is it not in the upper right of the namespace? I put the method there, and it worked the same way and checked other posts here, and he said that maybe the author was just trying to focus on other things, but I don’t quite understand why.