473,405 Members | 2,167 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,405 software developers and data experts.

Use [,][] as parameter

hi i am a newbie of C#

can i use [,][] as a ref parameter?

like this

main...
{
int[,][] idata as [100][200][];

define... = new [10 or other]...
Calc(ref idata);
}
public static void Calc ( ref int[,][] inputdata )
{
....
}

i run this but has an error
can i use [,][] as parameter
if yes,
any step i miss?

THANK YOU SO MUCH
Jul 5 '07 #1
5 1124
On Jul 5, 3:42 pm, "Macneed" <macn...@yahoo.com.hkwrote:
hi i am a newbie of C#

can i use [,][] as a ref parameter?
Yes.
like this
That's not your actual code. Please post a short but complete example
which demonstrates the problem, as per http://pobox.com/~skeet/csharp/complete.html.
(And when you mention that there's an error, it would be helpful to
say what it is.)

Jon

Jul 5 '07 #2
Hi Macneed,

Mi run this but has an error
Which error?

Mcan i use [,][] as parameter
Yes

Many step i miss?
Provide your code, please.

Coz that should work.

int[,][] idata = new int[1, 1][];
idata[0, 0] = new int[1] { 10 };
Calc(ref idata);

inputdata[0,0][0].ToString());

Kind Regards, Alex Meleta
[TechBlog] http://devkids.blogspot.com

Mhi i am a newbie of C#
M>
Mcan i use [,][] as a ref parameter?
M>
Mlike this
M>
Mmain...
M{
Mint[,][] idata as [100][200][];
Mdefine... = new [10 or other]...
M>
MCalc(ref idata);
M>
M}
M>
Mpublic static void Calc ( ref int[,][] inputdata )
M{
M...
M}
Mi run this but has an error
Mcan i use [,][] as parameter
Mif yes,
Many step i miss?
MTHANK YOU SO MUCH
M>
Jul 5 '07 #3
"Macneed" <ma*****@yahoo.com.hkschrieb im Newsbeitrag
news:46********@127.0.0.1...
>
i run this but has an error

In addition to what Jon said: What is the error, and in wich line it occurs.

Also note: You can pass an array (and an array of array ...) by reference,
but make sure this, is what you want to do. An Array is a reference type,
and it's content can be changed, even if it is not passed as reference.

Christof
Jul 5 '07 #4

"Jon Skeet [C# MVP]" <sk***@pobox.com¼¶¼g©ó¶l¥ó·s»D:11***************** *****@c77g2000hse.googlegroups.com...
On Jul 5, 3:42 pm, "Macneed" <macn...@yahoo.com.hkwrote:
>hi i am a newbie of C#

can i use [,][] as a ref parameter?

Yes.
>like this

That's not your actual code. Please post a short but complete example
which demonstrates the problem, as per
http://pobox.com/~skeet/csharp/complete.html.
(And when you mention that there's an error, it would be helpful to
say what it is.)

Jon
Thanks

static void Main(string[] args)
{
const int Method=100;

float[,][] SPay = new float[100, 100][];

for (int i = 0; i < 100; )
{
for (int j = 0; j < 100; )
{
SPay[i,j++] = new float[Method]; //[Method] is sth like
that
}
i++;
}

Calc(ref SPay);
}

public static void Calc(ref float[,][] pSPay)
{
for (int i = 0; i < 100; )
{
for (int j = 0; j < 100; )
{
for (int k = 0; k < 100; )
{
pSPay[i, j][k++] = 10;
}
j++;
}
i++;
}
}

sth like that
after run
the cmd screen go to the background
and two windows at the bottom of code screen
the left one show that
Locals
Name Value Type
+ pSPay {Dimensions:[100,100]} float[,][]
i 0 int
....
the right one is
Call Stack
xxx.exe!xxx.Program.Calc(ref float[,][]pSPay = {Dimensions:[100,100]}Line
1480
xxx.exe!xxx.Program.Main(string[] args = {Dimensions:[0]} Line 296 + 0xb
bytes

the windows message is type, not copy out,
so may be a little little different,

Thanks all


Jul 5 '07 #5
Macneed <ma*****@yahoo.com.hkwrote:

<snip>
sth like that
See http://pobox.com/~skeet/csharp/incomplete.html

It does look like you need to look at what ref really means though. See
http://pobox.com/~skeet/csharp/parameters.html

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Jul 5 '07 #6

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

Similar topics

4
by: Dan | last post by:
I've run into an interesting problem, and seemed to have stumped 3 newsgroups and 2 other forums. For some reason when I try to insert a record into a SQL table that has a Text column, the...
3
by: WGW | last post by:
Though I am a novice to MS SQL server (2000 I believe), I can do almost! everything I need. Maybe not efficiently, but usefully. However, I have a problem -- a complex query problem... I can...
2
by: John A Grandy | last post by:
Is there something special in XML about the name "Parameter" ... I am not able to XPATH query for nodes named "Parameter" <Root> <Category CategoryID="1"> <Elements> <Element...
2
by: PK | last post by:
Hi, I have an application that opens a Crystal report document and passes in a value to a parameter in the report (pointing to an Oracle DB). However, if I want to pass a "null" value to retrieve...
7
by: Richard Grant | last post by:
Hi. In c/C++ i can pass the address of a subroutine to another subroutine as an actual parameter How do I do that in VB .NET What should be the syntax for a parameter to receive the address of a...
4
by: Ranginald | last post by:
Hi, I'm having trouble passing a parameter from my default.aspx page to my default2.aspx page. I have values from a query in a list box and the goal is to pass the "catID" from default.aspx...
16
by: hzmonte | last post by:
Correct me if I am wrong, declaring formal parameters of functions as const, if they should not be/is not changed, has 2 benefits; 1. It tells the program that calls this function that the...
3
by: Ken Cox [Microsoft MVP] | last post by:
I've been going around and around on this one. I can't believe that it is "by design" as Microsoft says. Here's the situation: In *declarative* syntax, I'm trying to create a default datetime...
20
by: exipnakias | last post by:
Hello Guys. In a form I created a listbox which looks up the values of a table. I want: 1) ..to create a query where a parameter will be needed in order to be loaded. But I do not want to...
5
by: Trevisc | last post by:
Happy Thursday Everyone, I am trying to create a parameter that is one long varchar but that will be used in a SQL statement IN function: //string queryString = GetCurrentTitles(); //Below is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...

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.