I have class within class

 public class List
        {
            public int RecordCount { get; set; }
            public IEnumerable<ServiceElementItem> ServiceElement { get; set; }
        }

        public class ServiceElementItem
        {
            public int ServiceElementId { get; set; }
            public string ServiceElementBusinessId { get; set; }
            public string Description { get; set; }
            public string AlternateId { get; set; }
            public string CustomerName { get; set; }
            public string SiteName { get; set; }
            public string Location { get; set; }

And i am trying to get List of values and the code is

 public string GetServiceElementID(string orderLineID)
            {

           List<List> productAttributes = m_BusinessInterface.ListSEattributes(orderLineID).ToList();

            return productAttributes;
            }
       public IEnumerable<List> ListSEattributes(string orderLineId)
            {
                List<List> seItems = new List<List>();
                StringBuilder url = "";
                seItems = m_ServiceElementGetWebRestRequest.GetList(url.ToString());
                return seItems;

            }

And this should return back:

RecordCount: 1
ServiceElements: [1]

ServiceElementId: 1
ServiceElementBusinessId: "TEST"
Description: "Direct"
AlternateId: "12345"
CustomerName: "TEST CUSTOMER"
SiteName: "TEST SITE"

But it is returning back
RecordCount: 1
ServiceElements:null

Any idea how to return the list. I don't no how to resolve it.

Thanks in advance!

Hello samkri:
I'm not sure what the requiremenst are the for the project, but instead of declaring an IEnumerable why not just create a method that iterates through the list, displaying the necessary information? For example, if I have a list of dogs and each dog holds a name, breed, and age, and I wanted to display that information I might do something like:

public class Dog{
    public string Name {get; set;}
    public string Breed {get; set;}
    public int Age {get; set;}
    .
    .
    .
}

Then I would declare a list of Dogs like this:

List<Dog> dogList = new List<Dog>();

Of course at some point in the program you'd have to populate the list and then to look at the contents of the list I might create a method who's body was something like:

foreach(var dogInfo in dogList){
    Console.WriteLine("Dog's name: {0}\nDog's breed:{1}\nDog's age: {2}",
                        dogInfo.Name, dogInfo.Breed, dogInfo.Age);
}

Does that help? If not, send me your questions. :)

Tekkno

"I'm not sure what the requirements are" - I couldn't figure that out too!

Either way, it looks like it's been solved :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.