多维数组地狱 - C#与Java => C ++ ??? [英] Multidimensional Array Hell - C# versus Java => C++ ???

查看:74
本文介绍了多维数组地狱 - C#与Java => C ++ ???的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好日子,


i希望创建一个代表数据的数组,必须将
转移到pdf doc(iTextSharp)。 />

问题是,我的信仰似乎太宽松了。也就是说,(我有

c / c ++,perl和我在c#中的经验),我没有成功创造一个

多维数组。我没有在c#中创建

多维数组的经验。整个过程看起来对我来说太丑了,

我真的好了b $ b想到把所有的c#和java东西都扔到风中以便



再次使用旧的c或c ++。


或者......也许我太傻了。


所以,如果那里的某个程序员想要从他的萧条中吸取另一个深刻的程序员,那么

下面的代码有什么问题:( !!!!


使用系统;

命名空间arraytest {

class Class1 {

[STAThread]

static void Main(string [] args){

//不应该是以下语句创建一个三维数组



数组编号= Array.CreateInstance(typeof(Int32),10,4,2

);

//为什么不可能简单地做:

// numbers [] [] [] = new int [10] [4] [2]?!

尝试{

for(int i = 0; i< 10; i ++){

for(int y = 0; y < 4; i ++){

for(int j = 0; j< 2; j ++){

//请不要回答:你为什么不这样做

numbers.initialize()

//无言!

numbers.SetValue(100,i,y,j);

}

}

}

} catch(例外e){

System.Console.WriteLine(e.ToString());

System.Console.Read();

}

}

}

}


当然,我可以创建一个行类,它可以保存

数据和

将这些行对象放入一个数组中。但是我不想要不要给我的客户的工作站支付宝贵的费用。


请帮助我在这里......!


在此先感谢,Ole。


PS(对所有java程序员:你如何管理数组

是这样的并发症吗?我在java中看到类似丑陋的东西。)


if(noone.HelpsMe()){

throw新语言(进入大海);

}否则{


将System.Out&&和goto床;

}

床:

Goodday everybody,

i want to create an array that represents data, that has to
be transferred to a pdf doc ( iTextSharp ).

The problem is, that i seem too loose my faith. Namely, ( i have
experiences in
c/c++, perl and i thouht in c#, too ), i do not succeed in creating a
multidimensional array. I have no experience in creating
multidimensional array in c#. The whole process looks so ugly to me,
that i really
think of throwing all that c# and java stuff against the wind in order
to
use good old c or c++ again.

Or, ... perhaps i''m too stupid.

So, if some programmer out there would like to draw another, deep
fallen programmer out of his depressions, what is wrong with the
following code: (???!!!)

using System;
namespace arraytest {
class Class1 {
[STAThread]
static void Main( string[] args ) {
// shouldn''t the following statement create an 3-dimensional array
?
Array numbers = Array.CreateInstance( typeof ( Int32 ), 10, 4, 2
);
// and why isn''t possible simply to do :
// numbers[][][] = new int[10][4][2] ?!
try {
for( int i = 0; i < 10; i++ ) {
for ( int y = 0; y < 4; i++ ) {
for( int j = 0; j < 2; j++ ) {
// please do not answer : "why do you not do
numbers.initialize ( )
// wordless!
numbers.SetValue( 100, i,y,j );
}
}
}
}catch ( Exception e ) {
System.Console.WriteLine( e.ToString ( ) );
System.Console.Read( );
}
}
}
}

Sure, i could create a row - class, that would be able to hold the
data and
put those row objects into an array. But i don''t want''t to
overobjectize
my clients'' workstations!!

Please help me out here ...!

Thanks in advance, Ole.

PS ( to all the java programmers : how do you manage array
complications like this ? I saw something similar ugly in java . )

if ( noone.HelpsMe( ) ) {
throw new Languages ( "into the sea" );
}else {

put the System.Out && and goto bed;
}
bed:

推荐答案

Ole写道:
Ole wrote:
请在这里帮助我......!
Please help me out here ...!



http://www.programmersheaven.com/2/Les_CSharp_8_p1

-

那里是10种人。理解二元的人和那些没有b $ b的人。

http://code.acadx.com

(拉针回复)



http://www.programmersheaven.com/2/Les_CSharp_8_p1

--
There are 10 kinds of people. Thos who understand binary and those who
don''t.

http://code.acadx.com
(Pull the pin to reply)


好吧,我我自己也不太了解C#,但认为你似乎是使用错误的

语法




你将使用的rectangualr数组:

int [,] matrix = new int [10,20]并将其作为矩阵访问[3,4] = 5;


对于锯齿状数组,你可以使用:

int [] [] jarray = new int [3] []

jarray [0] = new int [10] ;

jarray [1] = new int [4];

jarray [2] = new int [1024];


要访问它,你可以使用jarray [2] [800] = 13;


它的价值,我的2美分!

欢呼

LK


" Ole" < OV ********* @ web.de>在消息中写道

news:c6 ************************** @ posting.google.c om ...
Well, I dont know a whole lot about C# myself, but think you seem to be
using the wrong
syntax.

For a rectangualr array you would use:
int[,] matrix = new int[10,20] and access it as matrix[3,4] = 5;

For a jagged array you would use:
int[][] jarray = new int[3][]
jarray[0] = new int[10];
jarray[1] = new int[4];
jarray[2] = new int[1024];

To access this, you would use jarray[2][800] = 13;

for what it''s worth, my 2 cents!
cheers
LK


"Ole" <ov*********@web.de> wrote in message
news:c6**************************@posting.google.c om...
Goodday everybody,

我想创建一个代表数据的数组,必须将其转移到pdf doc(iTextSharp)。

问题是,我的信仰似乎太宽松了。也就是说,(我有使用c / c ++,perl和我在c#中的经验),我没有成功创建一个多维数组。我没有在c#中创建多维数组的经验。整个过程看起来对我来说太难看了,
我真的想把所有的c#和java的东西都吹向风,以便
再次使用好的旧c或c ++或者......或者......也许我太傻了。

所以,如果那里的某个程序员想要画另一个,那个深刻的程序员出于他的沮丧,
以下代码有什么问题:(??? !!!)

使用System;
namespace arraytest {
class Class1 {
[STAThread]
static void Main(string [] args){
//不应该在下面的语句中创建一个三维数组

数组numbers = Array.CreateInstance(typeof(Int32),10,4,2
)//为什么不可能简单地做:
// numbers [] [] [] = new int [10] [4] [2]?!
尝试{
for(int i = 0; i< 10; i ++){
for(int y = 0; y< 4; i ++){
for(int j = 0; j< 2; j ++){
//请不要回答:为什么不做
numbers.initialize()
//无言!
numbers.SetValue(100,i,y,j);
System.Console.WriteLine(e.ToString());
System.Console.Read ();
}
}
}
}

当然,我可以创建一个行级,可以保持
data和
将这些行对象放入数组中。但是我不想过度支持我的客户的工作站!!

请帮助我在这里......!

PS(对所有java程序员来说:你如何管理数组这样的并发症?我在java中看到类似丑陋的东西。)

if(noone.HelpsMe()){
抛出新语言(进入大海);
}否则{

放置System.Out& ;&安培;和goto bed;
}
bed:
Goodday everybody,

i want to create an array that represents data, that has to
be transferred to a pdf doc ( iTextSharp ).

The problem is, that i seem too loose my faith. Namely, ( i have
experiences in
c/c++, perl and i thouht in c#, too ), i do not succeed in creating a
multidimensional array. I have no experience in creating
multidimensional array in c#. The whole process looks so ugly to me,
that i really
think of throwing all that c# and java stuff against the wind in order
to
use good old c or c++ again.

Or, ... perhaps i''m too stupid.

So, if some programmer out there would like to draw another, deep
fallen programmer out of his depressions, what is wrong with the
following code: (???!!!)

using System;
namespace arraytest {
class Class1 {
[STAThread]
static void Main( string[] args ) {
// shouldn''t the following statement create an 3-dimensional array
?
Array numbers = Array.CreateInstance( typeof ( Int32 ), 10, 4, 2
);
// and why isn''t possible simply to do :
// numbers[][][] = new int[10][4][2] ?!
try {
for( int i = 0; i < 10; i++ ) {
for ( int y = 0; y < 4; i++ ) {
for( int j = 0; j < 2; j++ ) {
// please do not answer : "why do you not do
numbers.initialize ( )
// wordless!
numbers.SetValue( 100, i,y,j );
}
}
}
}catch ( Exception e ) {
System.Console.WriteLine( e.ToString ( ) );
System.Console.Read( );
}
}
}
}

Sure, i could create a row - class, that would be able to hold the
data and
put those row objects into an array. But i don''t want''t to
overobjectize
my clients'' workstations!!

Please help me out here ...!

Thanks in advance, Ole.

PS ( to all the java programmers : how do you manage array
complications like this ? I saw something similar ugly in java . )

if ( noone.HelpsMe( ) ) {
throw new Languages ( "into the sea" );
}else {

put the System.Out && and goto bed;
}
bed:



好吧,呃......你的声明代码的代码不是甚至接近正确

语法的一件事。


string [,] names = new string [5,4];


对我来说很好(直接来自文档),


string [,,] names = new string [5,4,8];

" Ole" < OV ********* @ web.de>在消息中写道

news:c6 ************************** @ posting.google.c om ...
Well, uh... your code for declaring the array isn''t even close to the right
syntax for one thing.

string[,] names = new string[5,4];

works fine for me (straight out of the documentation), as does

string[,,] names = new string[5,4,8];
"Ole" <ov*********@web.de> wrote in message
news:c6**************************@posting.google.c om...
Goodday every everyone,

//为什么不可能简单地做:
// numbers [] [] [] = new int [10 ] [4] [2]?!
Goodday everybody,

// and why isn''t possible simply to do :
// numbers[][][] = new int[10][4][2] ?!



这篇关于多维数组地狱 - C#与Java =&gt; C ++ ???的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆