ASP.NET / C# : Function to return multiple numbers

Using ASP.NET/C#, how can I get my function to return a set of numbers that can be accessed like this?
        protected override void OnStart()
        {
                Temperature = GetTemperatureByDaysAgo(2);
                Console.WriteLine("Two days ago the high was " + Temperature.high + " and the low was " + Temperature.low + " and the average for the day was " + Temperature.average);
        }

        private ??? GetTemperatureByDaysAgo(int daysAgo)
        {
                return high=29, low=19, average=26;
        }

Open in new window

LVL 10
skijAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Kyle AbrahamsSenior .Net DeveloperCommented:
I would create a simple class for that:
public class Temperatures
{
   public int high;
   public int low;
   public int average;
}

  private Temperatures GetTemperatureByDaysAgo(int daysAgo)
        {
               Temperatures t = new Temperatures();

               t.high=29;
               t.low=19;
               t.average=26;

               return t;
        }

protected override void OnStart()
        {
                Temperatures Temperature = GetTemperatureByDaysAgo(2);
                Console.WriteLine("Two days ago the high was " + Temperature.high + " and the low was " + Temperature.low + " and the average for the day was " + Temperature.average);
        }

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AndyAinscowFreelance programmer / ConsultantCommented:
You could use the .net 'tuple' class (example usage is in the link):
https://msdn.microsoft.com/en-us/library/system.tuple%28v=vs.110%29.aspx

eg.
var Temperatures = new Tuple <int, int, int>(29, 19, 26);
return Temperatures;
0
käµfm³d 👽Commented:
While you can use the Tuple class, I don't suggest its usage. The Tuple class doesn't provide you with any information as to what the thing in its Item* members are. The caller just has to know what each Item means. I think the custom class route makes more sense, personally.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.