All These Things That I've Done

Apply the programming model to everyday programming problems
posts - 83, comments - 71, trackbacks - 4

My Links

News


View Gianluca Carucci's profile on LinkedIn

Tag Cloud

Archives

Post Categories

Image Galleries

Blogs

Links

Nuovamente un Quiz Sharp

Prendiamo questo Snippet di codice:

using System;
using System.Runtime.Remoting;
using System.Reflection;
using System.Threading;

namespace AppDomTest
{
  public class InvokeMethod
  {
    public static void Main( String[] argv )
    {
      AppDomainSetup info = new AppDomainSetup();
      AppDomain dom = AppDomain.CreateDomain("RemoteDomain", null, info);
      Foo f = dom.CreateInstance("AppDomTest", "AppDomTest.Foo").Unwrap() as Foo;
      Foo f2 = new Foo();
      Foo f3 = new Foo();
      f3.PrintCounter();
      AppDomain.Unload(dom);
     Console.Read();
    }
  }
  public class Foo : MarshalByRefObject
  {
    private static int _ci = 0;
    public Foo()
   {
     _ci++;
   }
   public void PrintCounter()
  {
      Console.WriteLine("Counter is {0}", _ci);
   }
  }
}

Cosa viene a visualizzato?

  • A. Counter is 1
  • B. Counter is 2
  • C. Counter is 3

 

Print | posted on mercoledì 20 ottobre 2004 20:46 | Filed Under [ C# Inside .NET ]

Powered by:
Powered By Subtext Powered By ASP.NET