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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T07:21:56+00:00 2026-05-12T07:21:56+00:00

I am developing in C#.net and I believe I need to use generics for

  • 0

I am developing in C#.net and I believe I need to use generics for the problem I have however I don’t know where to start.

Here are the steps I need to do:

  1. Get ID from user – DONE
  2. Query database table using ID – DONE
  3. Pull back one row – DONE
  4. Create a object type dependant on ID
  5. Populate object dependant on type

Different appointments require different information being pulled back (populated) from the database. For example one appointment might only require the users forename/surname where another may require forename/surname/dob.

I want the child class to execute first and then call the parent method. The issue is myAppointment is still be treated as a Appointment object not a DoctorAppointment/OtherAppointment once it has gone through the Switch statement. Where myAppointment is declared I actually dont know what type of object is it going to be

Here is the code I currently have:

        tblAppointment getAppointment = (from getApp in dc.tblAppointments
                                         where getApp.appID == Id
                                         select getApp).SingleOrDefault();

// Needs to be set the something. I really want this be to set to a generic type as I don’t really know what type it will be until it has been through the switch statement
Appointment myAppointment = null; 

            switch (getAppointment.tblAppointment.appTypeID)
            {
                case 2:
                    {
// Changes myAppointment from Appointment to DoctorsAppointment
                        myAppointment = new DoctorsAppointment();

                    }
                    break;
                case 1:
                    {
                        myAppointment = new OtherAppointment();
                    }
                    break;
                default:

                    break;

            }

// I want this to set myAppointment to DoctorsAppointment.Populate(getAppointment)
            return myAppointment.Populate(getAppointment);

Appointment is parent class.
DoctorsAppointment/OtherAppointment are child classes.

The Populate within the child classes require a parameter whereas the parent class doesn’t. The error I am currently recieveing is:

No overload for method 'Populate' takes '1' arguments

Hopefully I have explained myself enough.

Thanks,

Clare

  • 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-12T07:21:57+00:00Added an answer on May 12, 2026 at 7:21 am

    Suggest you take one of the inheritance answers above

    I thought it was worth asking if you are using LINQ to SQL? The kind of functionality you need is partially implemented for you if you have one table, that stores different kinds of objects.

    See here for an example

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

Sidebar

Related Questions

I'm working with C#.net developing applications for windows mobile 6, and i need get
I am developing c#.net solution where i have to calculate Start Date based on
When developing with .NET 3.5 I naturally use LINQ for data access. But for
I've been developing .net console applications using C# and have always just dictated what
While developing ASP.NET applications I often need to parse a boolean value given in
I'm developing a .NET Windows Forms application. I use the model-view-presenter design pattern, supervising
I am developing an ASP.Net MVC 3 Web application and believe my method of
I am developing asp.net with c#web application. I want to have a control in
I am developing ASP.NET 2.0 application using SQL Express 2005. I have attached my
I am developing asp.net mvc2 application and I use asp.net membership provider which uses

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.