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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T10:40:45+00:00 2026-06-08T10:40:45+00:00

I have this class as parent class: public partial class GetStuffResult { private int

  • 0

I have this class as parent class:

public partial class GetStuffResult
{

    private int _Id;

    private string _Name;

    public GetStuffResult()
    {
    }

    [Column(Storage="_Id", DbType="INT NOT NULL")]
    public int Id
    {
        get
        {
            return this._Id;
        }
        set
        {
            if ((this._Id != value))
            {
                this._Id = value;
            }
        }
    }

    [Column(Storage="_Name", DbType="NVarChar(100)")]
    public string Name
    {
        get
        {
            return this._Name;
        }
        set
        {
            if ((this._Name != value))
            {
                this._Name = value;
            }
        }
    }
}

This is base class which has same methods with exception of an extra method:

public partial class GetStuffResult1
{
    private int _Score;

    private int _Id;

    private string _Name;

    public GetStuffResult1()
    {
    }

    [Column(Storage="_Score", DbType="INT NOT NULL")]
    public int Id
    {
        get
        {
            return this._Score;
        }
        set
        {
            if ((this._Score != value))
            {
                this._Score = value;
            }
        }
    }

    [Column(Storage="_Id", DbType="INT NOT NULL")]
    public int Id
    {
        get
        {
            return this._Id;
        }
        set
        {
            if ((this._Id != value))
            {
                this._Id = value;
            }
        }
    }

    [Column(Storage="_Name", DbType="NVarChar(100)")]
    public string Name
    {
        get
        {
            return this._Name;
        }
        set
        {
            if ((this._Name != value))
            {
                this._Name = value;
            }
        }
    }
}

I have done inheritance before but i am totally confused how it will work in this scenario? How can i inherit GetStuffResult so that i can use its 2 methods and dont have to copy paste same code twice in GetStuffResult1.
Will appreciate if someone can give example with code as i am new to .net 3.5 and still trying to learn it.

  • 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-08T10:40:47+00:00Added an answer on June 8, 2026 at 10:40 am

    I am not sure if I correctly understood your question. (Your current code for GetStuffResult1 shouldn’t compile as you have define Id property twice.) If you are looking to inherit from GetStuffResult then this would do (See Inheritance):

    public partial class GetStuffResult1 : GetStuffResult
        {
            private int _Score;  
    
            public GetStuffResult1()
            {
            }
    
            [Column(Storage = "_Score", DbType = "INT NOT NULL")]
            public int Id
            {
                get
                {
                    return this._Score;
                }
                set
                {
                    if ((this._Score != value))
                    {
                        this._Score = value;
                    }
                }
            }
    
    
        }
    

    Notice that I have removed _Id and _Name from the child class. This however will give you warning that:

    GetStuffResult1.Id’ hides inherited member
    ‘ThreadConsoleApp.GetStuffResult.Id’. Use the new keyword if hiding
    was intended.

    The second thing I am thinking about your question if you are confused about using partial classes and you may need a single class in multiple source file. In that case you may use partial keyword. If that is the case and you don’t need inheritance then you need to use a single name for the class. e.g. GetStuffResult. In that particular case your GetStuffResult1 will become:

    public partial class GetStuffResult
        {
            private int _Score;  
    
            public GetStuffResult1()
            {
            }
    
            [Column(Storage = "_Score", DbType = "INT NOT NULL")]
            public int Id
            {
                get
                {
                    return this._Score;
                }
                set
                {
                    if ((this._Score != value))
                    {
                        this._Score = value;
                    }
                }
            }
    
    
        }
    

    This will be similar to having a single class with all the combined properties.

    Edit:

    To access the base class properties in the child class, you may use base keyword.

        base.Id = 0;
        base.Name = "SomeName";
    

    To access the base class properties from the object of GetStuffResult1, see the following example.

        GetStuffResult1 gsr1 = new GetStuffResult1();
        gsr1.Id = 0;
        gsr1.Name = "SomeName";
    

    Here gsr1.Name is from the base class, you may use different name for Id in either base or child class so that it can be more clearer.

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

Sidebar

Related Questions

Supposed I have two classes like this: public class Parent { public string Id
I have a parent form first.cs like this public partial class first : Form
I have this entities: public class Parent: AllDependant { /*Properties goes here*/ } public
I have a model that looks something like this: public abstract class Parent {
I have this class: Class B { private String D; private String E; }
I have a base class Parent like this: using System; using System.Collections.Generic; using System.Text;
I have written this clone method for when the parent of the Employee class
I have the following structure: class foo(object): class bar(object): def __init__(self, parent): self._parent=parent #this
Suppose i have this structure of elements: <div class=parent> <div class=something1> <div class=something2> <div
I have a table structured like this: <table> <tr id=id1 class=parent></tr> <tr class=id1></tr> <tr

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.