Lập trình hướng đối tượng – Hidden or shadow

class Book
{

void Show()
{

Console.WriteLine(“In Book”);

}

}
class StoryBook:Book
{

new void Show()
{

Console.WriteLine(“In Story book”);

}

static void Main()
{

Book b1=new storyBook();
b1.Show();

//call method of parent class
base.Show();

}

}

//output
In Story book

//Output of parent
In Book

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