The question is not as trivial as it may seem. It evokes some trickier question: how to illustrate the statement that the entry point method does not have to be the first method executed and how to
guarantee that some other method which is not an entry point would be executed before the call to the entry point.
I think this is the simplest possible solution:
using System;
static class EntryPointRacer {
static EntryPointRacer() { NotEntryPoint(); }
static void NotEntryPoint() {
Console.WriteLine(
"This string is written before the entry-point method call");
}
static void Main(string[] args) {
Console.WriteLine("This string is written in the entry-point method");
}
}
This is complete code. The effect of having a static field or property declaration I mentioned in Solution 1 would work if such member is used in the static constructor. Then the initialization of this static member will be required before the entry-point method call, which can also call a different static method. In this code sample, this technique would be redundant.
I will be much grateful if someone presents any essentially different solution.
—SA