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 8059709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T09:45:25+00:00 2026-06-05T09:45:25+00:00

namespace contest { class Program { static void Main(string[] args) { B b =

  • 0
namespace contest
{
    class Program
    {
        static void Main(string[] args)
        {
            B b = new B();
        }
    }

    class A {
        public A() {
            k();
        }
        private void k() {
            Console.WriteLine(base.GetType().Name);
        }        
    }

    class B : A {

    }
}

Can someone tell me why it outputs “B” instead of “Object”, doesn’t base.GetType() get A’s parent object therefore the root Object?

Thanks a lot

  • 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-05T09:45:26+00:00Added an answer on June 5, 2026 at 9:45 am

    That happens because

    base.GetType()
    

    means “call the GetType() method of parent class”, though you haven’t overriden it. Thus base.GetType() as well as this.GetType() would always return class B

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

Sidebar

Related Questions

using namespace std; class A { public: A() {} ~A() {} map<int, string*>& getMap()
Consider the following: using System; using System.Dynamic; namespace DynamicTest { class Program { static
namespace MyOldService { public MyNewService.AddressList ToPrivateAddressList() { MyNewService.AddressList privAddrList = new MyNewService.AddressList(); privAddrList.creator =
I have: Main Program Class - uses Library A Library A - has partial
using System; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Graphics; namespace proj { public class game
<Window x:Class=MyWindow xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml xmlns:src=clr-namespace:WpfApplication1 Title=ContactsSelector Height=300 Width=300> <Window.Content> <src:MyPage> <!--MyPage is a page
After namespace , class , struct , enum , for , foreach , while
I have an enum namespace Business { public enum Color { Red,Green,Blue } }
Is there a way to Import a static class in C# such as System.Math
A normal UserControl looks like this in XAML: <UserControl x:Class=mynamespace.foo ...namespaces...> <!-- content -->

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.