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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:41:23+00:00 2026-06-01T14:41:23+00:00

Please Consider this scenario: We have a base class called clsMain : class clsMain

  • 0

Please Consider this scenario:

We have a base class called clsMain :

class clsMain
{
    int P1{set; get;}
    int P2{set; get;}
    int P3{set; get;}
    string P4{set; get;}
    string P5{set; get;}
}

and I want to have these 2 obejcts from clsMain :

object1 psudo code:
{
    int P1{set; get;}
    int P2{set; get;}
    int P3{set; get;}    
}

and :

object2 psudo code:
{
    int P3{set; get;}
    string P4{set; get;}
    string P5{set; get;}
}

is it possible in c#? should I use specific type of class(abstract,…)?

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-01T14:41:24+00:00Added an answer on June 1, 2026 at 2:41 pm

    Inheritance is possible in C# as a first-class concept:

    public class BaseClass
    {
        public virtual string Name { get { return "Adam"; } }
    }
    
    public class ChildClass : BaseClass
    {
        public override string Name { get { return "Foo"; } }
    }
    

    To override something, you need to make it virtual and needs to have accessibility of anything other than private.

    In your instance you could possibly do something like:

    class clsMain
    {
        public virtual int P1{set; get;}
        public virtual int P2{set; get;}
        public virtual int P3{set; get;}
        public virtual string P4{set; get;}
        public virtual string P5{set; get;}
    }
    
    class object1 : clsMain
    {
        public override int P1{set; get;}
        public override int P2{set; get;}
        public override int P3{set; get;}    
    }
    
    class object2 : clsMain
    {
        public override int P3{set; get;}
        public override string P4{set; get;}
        public override string P5{set; get;}
    }
    

    Though if I’m being honest, your question isn’t very clear. Note, however, that C# does not support multiple inheritance of classes.

    Sounds like you want to filter out the properties. You cannot stop inherited members from being accessed (well, there is the new modifier, but this is sketchy at best). Instead you can use interfaces:

    interface Iobject1
    {
        int P1 { set; get; }
        int P2 { set; get; }
        int P3 { set; get; } 
    }
    
    interface Iobject2
    {
        int P3{set; get;}
        string P4{set; get;}
        string P5{set; get;}
    }
    
    class clsMain : Iobject1, Iobject2
    {
        public int P1{set; get;}
        public int P2{set; get;}
        public int P3{set; get;}
        public string P4{set; get;}
        public string P5{set; get;}
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please consider the following code: public class Person ( public string FirstName {get; set;}
i have trouble with building some projects. please consider this scenario: i have 2
Please consider this class: class A { public: //public in this example string a1;
Please consider the following scenario. I have a form with a property: class MyForm
Please consider this code: template<typename T> char (&f(T[1]))[1]; template<typename T> char (&f(...))[2]; int main()
Please consider the following simple use case: public class Foo { public virtual int
Please cosider this scenario: I have a form with 3 drop down list.I place
Please consider this -probably poorly written- example : class Command; class Command : public
Please consider this sql statements Create table abc (A int, B int ) insert
please consider this image: I have a table like this: Age Active Men/Women -------------------------------------------------

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.