Click here to Skip to main content
12,892,469 members (45,656 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# .NET WCF
i have two classes derived from same parent
public class Question
{
    string QuestionsID = "";
 
}
public class QuestionTrueOrFalse :Question
{
    public string Answer ="";
}
public class QuestionMultipleChoce : Question
{
    public List<MultipleChoiceOption> obj;
}
public class MultipleChoiceOption
{
    public int OptionMultipleChoiceID=0;
    public string OptionsTextAr="",Answer="";
}

and i want to return a list of question in a wcf service and i use a class
public class ReturnedObjectList<T>
{
   
   public List<T> ListItems = new List<T>();
   public string Status="" ,Message="";
}

 public ReturnedObjectList<Question> SelectQuestions(string ID)
    {
 
 ReturnedObjectList<Question> obj = new ReturnedObjectList<Question>();
        obj.ListItems.Add(new QuestionMultipleChoce());
        obj.ListItems.Add(new QuestionTrueOrFalse());
        return obj;
    }



while i check in postman i didn't get any result ."Could not get any respond"

What I have tried:

.code will work only what i add one type of object in list .ie 
<pre> ReturnedObjectList<QuestionMultipleChoce> obj = new ReturnedObjectList<QuestionMultipleChoce>();

.Is there any way to send different object such as above in same list
Posted 21-Apr-17 1:41am
Comments
Ralf Meier 21-Apr-17 9:18am
   
You shoud make a List<object>. In this List you could add each Class or Control.
When you read it out of the List you assign the readed item to a new item which has the right Type.
Now you can Access each Property of this new Item ...
kosmaskaf 5 days ago
   
you could return an object with two lists
rajin kp 3 days ago
   
i want to add it in a sing list
Ralf Meier 3 days ago
   
Have you tried what I have described ...?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.170424.1 | Last Updated 21 Apr 2017
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100