Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7777431
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:08:24+00:00 2026-06-01T18:08:24+00:00

I am trying to understand inheritance in C# and that is why I am

  • 0

I am trying to understand inheritance in C# and that is why I am trying out some samples, but I got to know that with new keyword or without new keyword things are same.

Then why we need new keyword?

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }

    private void Form1_Load(object sender, EventArgs e)
    {
        try
        {
            List<int> col = new List<int>();
            Class1 c1 = new Class1();
            Class2 c11 = new Class2();
            Class1 c111 = new Class3();
            c1.setmessage();
            c11.setmessage();
            c111.setmessage();
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }

    }
   
}
class Class1
{
    private string member;

    public  void setmessage()
    {
        MessageBox.Show("Class1");
    }
}

class Class2 : Class1
{
    private string member;

    public  void setmessage()
    {
        MessageBox.Show("Class2");
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T18:08:25+00:00Added an answer on June 1, 2026 at 6:08 pm

    The new keyword, in this context signifies shadowing of a method.

    This means that you are not overriding the method from the base class, but writing a completely separate one, as far as inheritance is concerned.

    A compiler issues a warning if it is not used for an overridable method that isn’t being overridden as most of the time this is an error and the method should simply be overridden. Having the new keyword there shows that shadowing was an explicit decision.

    See Difference between shadowing and overriding in C#?.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to understand something that I don't know how to describe because I don't
I am trying to really understand how inheritance and the super keyword work. I
Trying to understand the options for will_paginate's paginate method: :page — REQUIRED, but defaults
Trying to understand a little more about Crockford's approach to Prototypical Inheritance whereby he
I m trying to understand Interfaces so that I can implement them in my
I'm trying to grasp the Open/Closed principle (in my case for PHP, but that
I am trying to understand the inheritance mappings in EF4. My database has two
I am a newbie and trying to understand concepts of inheritance and design patterns.
Firstly, I know how to fix the problem, I'm just trying to understand why
I am trying to figure out an interesting multiple inheritance issue. The grandparent is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.