[C#]기본상속 vitual override > C#/.Net/Blazor/IIS

본문 바로가기
사이트 내 전체검색

C#/.Net/Blazor/IIS

[C#]기본상속 vitual override

페이지 정보

작성자 sbLAB 댓글 0건 조회 4,440회 작성일 18-07-25 17:28

본문


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            ntop nt = new ntop();
            nt.run1();
            nt.show();
            Console.ReadKey();
        }
    }
 
    //부모클래스
    class top
    {
        //virtual 을 선언하여 자식클래스에서 overiding  가능함을 알려줌
        virtual public void run1()
        {
            Console.WriteLine("run1 입니다!");
        }
    }
 
 
    //자식클래스(부모상속)
    class ntop : top
    {
 
        //virtual - override 
        public override void run1()
        {
            Console.WriteLine("ntop run1 입니다!");
        }
 
        public void show()
        {
            Console.WriteLine("ntop show 입니다!");
        }
    }
 
 
}


 

댓글목록

등록된 댓글이 없습니다.

회원로그인

접속자집계

오늘
421
어제
396
최대
1,279
전체
222,471

그누보드5
Copyright © sebom.com All rights reserved.