locked
list question RRS feed

  • Question

  • User-2012457684 posted

    I know that I can have a list of lists  List<List<string>>  but is it possible to have a list of lists of lists?  List<List<List<string>>>  

    Wednesday, October 30, 2019 7:33 PM

All replies

  • User475983607 posted

    I know that I can have a list of lists  List<List<string>>  but is it possible to have a list of lists of lists?  List<List<List<string>>>  

    Yes. Are you having a problem creating a List<List<List<string>>>?

    Wednesday, October 30, 2019 7:37 PM
  • User-474980206 posted

    sure, you can nest as deep as you want, similar to muti-dimensional arrays

    Wednesday, October 30, 2019 7:38 PM
  • User753101303 posted

    Hi,

    Any reason for thinking it won't work? What if you just take a couple of minutes to try or be explicit if you ran into a problem when trying.

    That said I rarely if ever have seen this. You may want to explain what is your use case but you may have easier to use data structures depending on what you are trying to do...

    Wednesday, October 30, 2019 8:17 PM
  • User-2012457684 posted

    I am converting a report that was originally written in Basic.  Then when everything went online in the mid 90's everything was written in VBScript and classic asp.    Now I am rewriting our admin site using MVC  and have one report that used a call to a subroutine from the report page to display the info  inside the subroutine it used multiple single dimension arrays and one multi dimensional array. 

    What I am working on now is the part of the report that displays job fit potential to people that have taken the assessment.   There are 18 different job families that the people can select as few or as many as they like.   Then in the report it loops through each family  that is selected getting all of the jobs for that family and compares the benchmark to the individual scores on 7 mental aptitudes, 10 personality dimensions and 2 validity scales.    It  then assigns the jobs to one of five different categories   "Excellent Potential", "Very Good Potential", "Good Potential", "Fair" or "Not Recommended".   Once that is done I need to display on the page.   Each Job under each of the five categories when they have at least fair or better potential  and if all are not recommended it will display a message saying that the job family does not have any potential.   

    I have all the Controller code done that determines the fit  now I need to create the lists in the controller.   basically it would be list of jobs  inside the list of potential fit  inside the list of job families.    

    My thought is to create a couple new classes where each has a list as one of the properties which should help me then display the info on the view

    Wednesday, October 30, 2019 8:49 PM
  • User753101303 posted

    The original code doesn't use VBScript classes at all ? Rather than really using a "raw" list of list of list of strings it seems to me you could move further to an https://en.wikipedia.org/wiki/Object-oriented_programming design.

    For example you could use  https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.dictionary-2?view=netframework-4.8 the key being the family name and the value a dictionary with a job name key and the potential value or move even further and have a List<Family>, Family having Name and a Likst<Job> property etc...

    If the final rendition is a crossttab, it could be even a flat list using a DataTable etc from which you could create a crosstab etc...

    It really depends on what you want and you don"'t have to go too far but for now it seems you try to adapt non OOP code and that you could move your design a bit more toward OOP to get something simpler to manage...

    Ah: saw you last sentence. So it seems you real intent is already to use classes rather than really a List<List<List<srtring>>> ? Make sure to be accurate enough when it matters...

    Wednesday, October 30, 2019 9:22 PM