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

  • SEARCH
  • Home
  • 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 938545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T21:39:44+00:00 2026-05-15T21:39:44+00:00

Possible Duplicate: Multiple Inheritance in C# In the following example, I want the Shirt

  • 0

Possible Duplicate:
Multiple Inheritance in C#

In the following example, I want the Shirt to automatically inherit the properties of both the Material and Pigment classes. Is this even possible in C#?

public class Material
{
    public enum FabricTypes { Cotton, Wool, Polyester, Nylon }
    public FabricTypes Fabric { get; set; }
    public Color Color { get; set; }
}

public class Pigment
{
    public enum PigmentQualities { Fine, Average, Poor }
    public PigmentQualities Quality { get; set; }
    public Color Color { get; set; }
}

public class Shirt : Material //, Pigment
{
    public Shirt()
    {
        Fabric = FabricTypes.Cotton;
        Color = new Color();
        //Quality = PigmentQualities.Fine;
    }
}

I’m having a hard time furnishing a better example, but this is essentially what I’m trying to do. I realize I can create interfaces, but those won’t automatically inherit the properties. See, because I don’t want to have to manually punch in all those properties every time I create a class that is similar to Shirt.

  • 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-05-15T21:39:45+00:00Added an answer on May 15, 2026 at 9:39 pm

    C# doesn’t allow to inherit from multiple classes.

    But why do you do it like this? Shirt could have 2 properties instead: Material and Pigment. Those could be set when you initialize a Shirt instance like passing it in a constructor with those properties set. Or create a constructor in which you can pass certain properties and instantiate Material and Pigment in that constructor.

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

Sidebar

Related Questions

Possible Duplicate: Multiple Inheritance in C# I have two classes Class A and Class
Possible Duplicate: returning multiple values from a function For example if you want a
Possible Duplicate: Bind multiple events to jQuery 'live' method I have the following function:
Possible Duplicate: Should C# include multiple inheritance? One of my friend asked me the
Possible Duplicate: Removing multiple classes (jQuery) how can we remove multiple classes from one
Possible Duplicate: Combine Multiple child rows into one row MYSQL I have following table,
Possible Duplicate: Can Super deal with multiple inheritance? Python inheritance? I have a class
Possible Duplicate: Multiple select options in one row I have the following code but
Possible Duplicate: Why to use Interfaces ? Multiple Inheritance vs Interfaces ? Benefits of
Possible Duplicate: Objective-C multiple inheritance In my application, I need to add SideSwipeTableViewController and

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.