Quiz #2

2

Posted on : 11-04-2007 | By : matteosp | In : C#, Quiz

Look at the following snippet:

public class Foo
{
    protected Foo() {}
}

public class Var : Foo
{
    Var(): base() {}

    void Main()
    {
        Foo foo = new Foo();
    }
}

Now tell me if it can be successfully compiled:

  1. both in 1.1 and 2.0
  2. only in 1.1
  3. only in 2.0
  4. neither in 1.1 nor in 2.0

Comments

Well I’m new to .NET – coming from Microsoft Navision development – but I figure a class with a Main method is supposed to be static, shouldn’t it? Otherwise there would be multiple entry points via instantiation. So I think it’s not supposed to be compiled with anything.

No Miklos (not sure if this is your name or if Hollender is), the fact that usually a static method named “Main” is the entry point for an application is only the Visual Studio default behavior.

The fact I called that method “Main” is not related to the response.

Sorry not to have replied before, I have some troubles with comments notification.

Post a comment