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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:09:52+00:00 2026-05-16T05:09:52+00:00

This question came to my mind while I am reading the post Why doesn’t

  • 0

This question came to my mind while I
am reading the post Why doesn’t C#
support multiple inheritance?

from MSDN Blog.

At first look at the following code:

using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{
    class A
    {
        int num;
        public A()
        {
            num = 0;
        }
        public A(int x)
        {
            num = x;
        }
        public override int GetHashCode()
        {
            return num + base.GetHashCode();
        }
    }
    class B : A
    {
        int num;
        public B()
        {
            num = 0;
        }
        public B(int x)
        {
            num = x;
        }
        public override int GetHashCode()
        {
            return num + base.GetHashCode();
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            A a = new A();
            B b = new B();
            Console.Write(a.GetHashCode() + " " + b.GetHashCode());
            Console.Read();
        }
    }
}

Object class is the ultimate base class of all classes. So it is the base class of A and B both in my program and also make A as a base class of B. So B has now two base class, one is A and another is Object. I override one method GetHashCode() of Object Class in class A and B both. But in class B, base.GetHashCode() method returns the return value of GetHashCode() method of class A. But I want this value from Object class. How can I get that?

  • 1 1 Answer
  • 1 View
  • 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-05-16T05:09:53+00:00Added an answer on May 16, 2026 at 5:09 am

    B has only one base class, and that is A. A has one base class, and that is object. There is no multiple inheritance; object is only inherited by classes that don’t already inherit from something else.

    If you still think you need to call object.GetHashCode(), there is a very hacky workaround to do this in the question How to invoke (non virtually) the original implementation of a virtual method?.

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

Sidebar

Related Questions

This is a question that came to mind while reading the brilliant answer by
This question came into my mind while generating sample data for a SO-answer. I
While writing a simple server-client application, this question came in my mind. When someone
This question came to mind after reading the answer to this question; which basically
This question came to my mind while working on 2 projects in AI and
This question came to mind while I was writing a class that iterates over
This question came to my mind when I was experimenting with multiple events bound
This question came to my mind when I learned C++ with a background of
What is the difference between above two? This question came to my mind because
This question came up from what I see on a clients side: Intermittent Connection

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.