2014-04-29 16 views
6

무슨 이런 ApplicationContext 사용하여 프로그램 작성의 차이 :ApplicationContext를 사용하면 어떤 이점이 있습니까?

using System; 
using System.Windows.Forms; 

namespace Test 
{ 
    class Test 
    { 
     static void Main(string[] args) 
     { 
      Application.Run(new Context(args)); 
     } 
    } 

    class Context : ApplicationContext 
    { 
     public Context(string[] args) 
     { 
      //the program 
      Environment.Exit(1); 
     } 
    } 
} 

및 표준 Main를?

namespace Test 
    { 
     class Test 
     { 
      static void Main(string[] args) 
      { 
       //the program 
      } 
     } 
    } 

답변

5

한 세트의 프로그램에 공통된 기능을 가지고 있고 다른 프로그램 세트에 대해 몇 가지 기능을 갖고 있지만 두 세트에는 공통된 기능이 있다고 가정 해 보겠습니다. class BaseContext : ApplicationContext을 사용하면 두 가지 모두에 공통된 기능을 수행 한 다음 BaseContext에서 상속하여 특정 세트 기능을 구현할 수 있습니다. 기본적으로 '정상적인'다형성과 같은 이점을 얻습니다.

관련 문제