Quiz #2

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
Advertisements

~ by Matteo on April 11, 2007.

2 Responses to “Quiz #2”

  1. 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.

  2. 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.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: