Click here to Skip to main content
15,888,984 members
Home / Discussions / C#
   

C#

 
AnswerRe: Using IList.Contains<> to search nested members? Pin
BobJanova22-Aug-12 0:41
BobJanova22-Aug-12 0:41 
Questionplz help with ghe following.... Pin
joy madalane21-Aug-12 12:59
joy madalane21-Aug-12 12:59 
AnswerRe: plz help with ghe following.... Pin
Wes Aday21-Aug-12 15:49
professionalWes Aday21-Aug-12 15:49 
JokeRe: plz help with ghe following.... Pin
Mycroft Holmes21-Aug-12 20:07
professionalMycroft Holmes21-Aug-12 20:07 
AnswerRe: plz help with ghe following.... Pin
OriginalGriff21-Aug-12 21:09
mveOriginalGriff21-Aug-12 21:09 
GeneralRe: plz help with ghe following.... Pin
joy madalane21-Aug-12 21:27
joy madalane21-Aug-12 21:27 
GeneralRe: plz help with ghe following.... Pin
OriginalGriff21-Aug-12 21:47
mveOriginalGriff21-Aug-12 21:47 
QuestionDifferent object depending on variable value Pin
suzyb21-Aug-12 3:50
suzyb21-Aug-12 3:50 
I am trying to implement a multi page form on a site that will be used for 3 different types of applicant. Each of these 3 types will fill in their personal details before filling in different sections of the form depending on type.

I currently have a base class with the shared personal details and derived classes for the 3 specific types. In my form however I don't know how to create the correct object based on the type of applicant without having a lot of duplicate code.

Here is a cut down example of my code. This is an example of the classes

C#
public class BaseApplication
{
    public bool FirstName { get; set; }
    public bool LastName { get; set; }

    public virtual void Save()
    {
        // write first name and last name to database
    }
}

public class StudentApplication : BaseApplication
{
    public bool SupportNeeds { get; set; }

    public override void Save()
    {
        base.Save();

        // write support needs to database
    }
}


And this the part of the page where I want to create the object.
C#
?? app;
switch (courseType)
{
    case "31":
        app = new StudentApplication();
        break;
    case "32":
        app = new AdultApplication();
        break;
}

app.FirstName = FirstName.Text;
app.LastName = LastName.Text;
app.SupportNeeds = SupportNeeds.Text;

app.Save();

I don't know what to declare app as as it can be one of 3 types depending on the value of courseType.
AnswerRe: Different object depending on variable value Pin
OriginalGriff21-Aug-12 4:06
mveOriginalGriff21-Aug-12 4:06 
GeneralRe: Different object depending on variable value Pin
Pete O'Hanlon21-Aug-12 4:31
mvePete O'Hanlon21-Aug-12 4:31 
AnswerRe: Different object depending on variable value Pin
Pete O'Hanlon21-Aug-12 4:40
mvePete O'Hanlon21-Aug-12 4:40 
AnswerRe: Different object depending on variable value Pin
Eddy Vluggen21-Aug-12 4:53
professionalEddy Vluggen21-Aug-12 4:53 
GeneralRe: Different object depending on variable value Pin
suzyb21-Aug-12 5:40
suzyb21-Aug-12 5:40 
GeneralRe: Different object depending on variable value Pin
Eddy Vluggen21-Aug-12 5:46
professionalEddy Vluggen21-Aug-12 5:46 
AnswerRe: Different object depending on variable value Pin
jschell22-Aug-12 8:50
jschell22-Aug-12 8:50 
QuestionAutomatically optimize all tables in a MySQL database Pin
Alagiri.periyasamy@merrillcorp.com21-Aug-12 1:46
Alagiri.periyasamy@merrillcorp.com21-Aug-12 1:46 
AnswerRe: Automatically optimize all tables in a MySQL database Pin
Eddy Vluggen21-Aug-12 1:51
professionalEddy Vluggen21-Aug-12 1:51 
GeneralRe: Automatically optimize all tables in a MySQL database Pin
Alagiri.periyasamy@merrillcorp.com21-Aug-12 2:05
Alagiri.periyasamy@merrillcorp.com21-Aug-12 2:05 
AnswerRe: Automatically optimize all tables in a MySQL database Pin
Eddy Vluggen21-Aug-12 2:17
professionalEddy Vluggen21-Aug-12 2:17 
QuestionLinq - Conditions for two categories in parallel Pin
Ronenb21-Aug-12 1:18
Ronenb21-Aug-12 1:18 
AnswerRe: Linq - Conditions for two categories in parallel Pin
Wayne Gaylard21-Aug-12 3:21
professionalWayne Gaylard21-Aug-12 3:21 
AnswerMessage Removed Pin
21-Aug-12 3:40
professionalN_tro_P21-Aug-12 3:40 
GeneralRe: Linq - Conditions for two categories in parallel Pin
Ronenb22-Aug-12 20:54
Ronenb22-Aug-12 20:54 
GeneralRe: Linq - Conditions for two categories in parallel Pin
Ronenb26-Aug-12 21:59
Ronenb26-Aug-12 21:59 
GeneralMessage Removed Pin
27-Aug-12 2:41
professionalN_tro_P27-Aug-12 2:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.