473,398 Members | 2,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

getting multiple values returned from a method

Hi All,

I'm trying to write a method where I pass three arguments and the method
returns six values. All the values will be doubles. First, is it possible to
get multiple values returned by a method? Second, how do I do it? I know how
to write the method, pass arguments to it and get a single value returned
but how do I pass multiple values back? Last, how do I reference the various
values returned? I assume there is some array used here. Any examples are
greatly appreciated.

Thanks,
Scott


Nov 17 '05 #1
5 2227
Just return an array of type double.

public double[] MyMethod (...)
{
...
}

--
Tim Wilson
..Net Compact Framework MVP

"Homer Simpson" <homer@moe's.com> wrote in message
news:Oy**************@TK2MSFTNGP15.phx.gbl...
Hi All,

I'm trying to write a method where I pass three arguments and the method
returns six values. All the values will be doubles. First, is it possible to get multiple values returned by a method? Second, how do I do it? I know how to write the method, pass arguments to it and get a single value returned
but how do I pass multiple values back? Last, how do I reference the various values returned? I assume there is some array used here. Any examples are
greatly appreciated.

Thanks,
Scott

Nov 17 '05 #2
pass a collection back...

ie.. an array or arraylist
"Homer Simpson" <homer@moe's.com> wrote in message
news:Oy**************@TK2MSFTNGP15.phx.gbl...
Hi All,

I'm trying to write a method where I pass three arguments and the method
returns six values. All the values will be doubles. First, is it possible to get multiple values returned by a method? Second, how do I do it? I know how to write the method, pass arguments to it and get a single value returned
but how do I pass multiple values back? Last, how do I reference the various values returned? I assume there is some array used here. Any examples are
greatly appreciated.

Thanks,
Scott

Nov 17 '05 #3
>
I'm trying to write a method where I pass three arguments and the method
returns six values. All the values will be doubles. First, is it possible
to get multiple values returned by a method? Second, how do I do it? I
know how to write the method, pass arguments to it and get a single value
returned but how do I pass multiple values back? Last, how do I reference
the various values returned? I assume there is some array used here. Any
examples are greatly appreciated.

Thanks,
Scott

Well returning an array as other have said or....

void Test(out double d1, out double d2, out double d3)
{
d1 = 1.1;
d2 = 2.2;
d3 = 3.3;
}

void UseTest()
{
double d1;
double d2;
double d3;

Test(out d1, out d2, out d3);
}
Nov 17 '05 #4

"Lorad" <je*********@hotmail.come> wrote in message
news:bM*****************@newssvr17.news.prodigy.co m...

I'm trying to write a method where I pass three arguments and the method
returns six values. All the values will be doubles. First, is it possible
to get multiple values returned by a method? Second, how do I do it? I
know how to write the method, pass arguments to it and get a single value
returned but how do I pass multiple values back? Last, how do I reference
the various values returned? I assume there is some array used here. Any
examples are greatly appreciated.

Thanks,
Scott

Well returning an array as other have said or....

void Test(out double d1, out double d2, out double d3)
{
d1 = 1.1;
d2 = 2.2;
d3 = 3.3;
}

void UseTest()
{
double d1;
double d2;
double d3;

Test(out d1, out d2, out d3);
}


I recently used out parameters in a project and FxCop complained. Check
http://www.gotdotnet.com/team/fxcop/...arameters.html
for the details.
Nov 17 '05 #5
In addition to the other excellent suggestions, you could define a structure
or class that would hold your values, then return an instance of the
structure or class.

"Homer Simpson" <homer@moe's.com> wrote in message
news:Oy**************@TK2MSFTNGP15.phx.gbl...
Hi All,

I'm trying to write a method where I pass three arguments and the method
returns six values. All the values will be doubles. First, is it possible to get multiple values returned by a method? Second, how do I do it? I know how to write the method, pass arguments to it and get a single value returned
but how do I pass multiple values back? Last, how do I reference the various values returned? I assume there is some array used here. Any examples are
greatly appreciated.

Thanks,
Scott

Nov 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

66
by: Darren Dale | last post by:
Hello, def test(data): i = ? This is the line I have trouble with if i==1: return data else: return data a,b,c,d = test()
9
by: Kelly Vernon | last post by:
I have a standard ASP page that appends to an xml page. Currently if there is more than one person attempting to append to the same XML file at a time. One user will have the ability to append,...
21
by: Michael Bierman | last post by:
Please forgive the simplicy of this question. I have the following code which attempts to determine the color of some text and set other text to match that color. It works fine in Firefox, but does...
4
by: Amy | last post by:
Hello, I've been struggling to learn C#.NET for a while now. I've made some progress, but I'm easily stumped. :( What's stumping me today is this: I've got a stored procedure (SQL) that...
2
by: Martin Raychev | last post by:
Hi all, I have the following problem: I have a private method that returns a SqlDataReader. For this to work I have not to close the DB connection in the above method. I do this only to
7
by: Aaron Gray | last post by:
I put together the following code to get the href's parameters :- function GetParameters() { var arg = new Object(); var href = document.location.href; if ( href.indexOf( "?") != -1) { var...
6
by: sathyashrayan | last post by:
Dear Group, Please look at the following demo link. http://www.itsravi.com/demo/new_pms/admin/addproject.php
2
ADezii
by: ADezii | last post by:
The incentive for this Tip was an Article by the amazing Allen Browne - I considered it noteworthy enough to post as The Tip of the Week in this Access Forum. Original Article by Allen Browne ...
14
by: =?Utf-8?B?QmVu?= | last post by:
Hi all, I'm trying to understand the concept of returning functions from the enclosing functions. This idea is new to me and I don't understand when and why I would need to use it. Can someone...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.