• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 685
  • Last Modified:

How to encapsulate a list<double> in C#

I know how to do it with a string but I'm lost when trying to do it with a double. Here's what I have, can someone point out what I'm doing wrong?

class PollenCountList
        {
           

            List<double> pollenList = new List<double>();



            public PollenCountList()   //
            {
                PollenList = new List<pollenList>();

            }

            public void Add(double PollenHighCount, double PollenLowCount, double PollenAverage)
            {

                PollenList.Add(new PollenCountList(PollenHighCount, PollenLowCount, PollenAverage));
            }
        }

Best,
MH

0
MHenry
Asked:
MHenry
1 Solution
 
Miguel OzSoftware EngineerCommented:
Are you trying to create a list of a list of doubles
If so your code needs to be:List<List<double>>  see attached code.

class PollenCountList
    {

        List<List<double>> pollenList = new List<List<double>>();

        public PollenCountList()   //
        {
        }

        public void Add(double PollenHighCount, double PollenLowCount, double PollenAverage)
        {

            List<double> list = new List<double>();
            list.Add(PollenHighCount);
            list.Add(PollenLowCount);
            list.Add(PollenAverage);
            pollenList.Add(list);
        }
    }

Open in new window

0
 
milindsmCommented:
Can you please post the problem code and the exact error that you are getting...???
0
 
MHenryAuthor Commented:
Thanks, that looks like it!

0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now