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

Two Dimensional Array

Hi all Pro,

I have the class call "Person", and I do declare two dimensional array type
of string inside this class which will keep "First_Name" and "Last_Name" as
the record. When I try to serialize it by using XMLSerializer, I got error
like this:

An unhandled exception of type 'System.InvalidOperationException' occurred
in system.xml.dll
Additional information: There was an error reflecting type
'WindowsApplication1.Array_Serialize'.

Does some Pro out there did encounter this problem before? I did try to
serialize with one dimensional array and it works fined, but not for two
dimensional array. May some Pro help please. Thanks you all in advance and
I'm deeply appreciated for your help. Have a good one...

Kate
Nov 15 '05 #1
5 13141
can you send ur code or code snippet? 'coz it looks like u have a type
called Array_Serialize in ur code. What is that for?

"cql60" <cq***@yahoo.com> wrote in message
news:eP**************@tk2msftngp13.phx.gbl...
Hi all Pro,

I have the class call "Person", and I do declare two dimensional array type of string inside this class which will keep "First_Name" and "Last_Name" as the record. When I try to serialize it by using XMLSerializer, I got error
like this:

An unhandled exception of type 'System.InvalidOperationException' occurred
in system.xml.dll
Additional information: There was an error reflecting type
'WindowsApplication1.Array_Serialize'.

Does some Pro out there did encounter this problem before? I did try to
serialize with one dimensional array and it works fined, but not for two
dimensional array. May some Pro help please. Thanks you all in advance and
I'm deeply appreciated for your help. Have a good one...

Kate

Nov 15 '05 #2
"cql60" <cq***@yahoo.com> wrote:
I did try to serialize with one dimensional array and
it works fined, but not for two dimensional array.


Try using an array of arrays instead.

public int[,] iArray = new int[10, 10]; // This won't serialise.
public int[][] iArray = new int[10][]; // This will serialise.

Unfortunately, it's more of a chore to initialise the array elements.

for (int iElement = 0; iElement < 10; iElement++)
{
iArray[iElement] = new int[10];
}

P.

--
www.CL4.org
Nov 15 '05 #3
Thanks you very much, Paul. I'm appreciated.

I did this and it did not work.
**************************************************

public Array iArray;

public void initialize_Array()

{

iArray = Array.CreateInstance( typeof(Int32), 10, 10 );

for ( int i = iArray.GetLowerBound(0); i <= iArray.GetUpperBound(0); i++ )

{

for ( int j = iArray.GetLowerBound(1); j <= iArray.GetUpperBound(1); j++ )

{

iArray.SetValue( (i*100)+(j*10), i, j );

}

}

}

************************************************** *******

"Paul E Collins" <fi******************@CL4.org> wrote in message
news:bu**********@sparta.btinternet.com...
"cql60" <cq***@yahoo.com> wrote:
I did try to serialize with one dimensional array and
it works fined, but not for two dimensional array.


Try using an array of arrays instead.

public int[,] iArray = new int[10, 10]; // This won't serialise.
public int[][] iArray = new int[10][]; // This will serialise.

Unfortunately, it's more of a chore to initialise the array elements.

for (int iElement = 0; iElement < 10; iElement++)
{
iArray[iElement] = new int[10];
}

P.

--
www.CL4.org

Nov 15 '05 #4
I beleive that serialization doesn't work with Multi-Dim Arrays.
Create a class with LastName and FirstName as members and then serialize the
array of that class.
-
Paul

"cql60" <cq***@yahoo.com> wrote in message
news:eP**************@tk2msftngp13.phx.gbl...
Hi all Pro,

I have the class call "Person", and I do declare two dimensional array type of string inside this class which will keep "First_Name" and "Last_Name" as the record. When I try to serialize it by using XMLSerializer, I got error
like this:

An unhandled exception of type 'System.InvalidOperationException' occurred
in system.xml.dll
Additional information: There was an error reflecting type
'WindowsApplication1.Array_Serialize'.

Does some Pro out there did encounter this problem before? I did try to
serialize with one dimensional array and it works fined, but not for two
dimensional array. May some Pro help please. Thanks you all in advance and
I'm deeply appreciated for your help. Have a good one...

Kate

Nov 15 '05 #5
Thanks you so much for your input, I'm very appreciated. As Paul E Collins
said, serialize only work for jagged arrays, and I did make it work(
Serialized to XML file ).
"Paul Hetherington" <pN*****************@vNiOsSuPaAlMstatement.com> wrote in
message news:%2****************@TK2MSFTNGP12.phx.gbl...
I beleive that serialization doesn't work with Multi-Dim Arrays.
Create a class with LastName and FirstName as members and then serialize the array of that class.
-
Paul

"cql60" <cq***@yahoo.com> wrote in message
news:eP**************@tk2msftngp13.phx.gbl...
Hi all Pro,

I have the class call "Person", and I do declare two dimensional array

type
of string inside this class which will keep "First_Name" and "Last_Name"

as
the record. When I try to serialize it by using XMLSerializer, I got error like this:

An unhandled exception of type 'System.InvalidOperationException' occurred in system.xml.dll
Additional information: There was an error reflecting type
'WindowsApplication1.Array_Serialize'.

Does some Pro out there did encounter this problem before? I did try to
serialize with one dimensional array and it works fined, but not for two
dimensional array. May some Pro help please. Thanks you all in advance and I'm deeply appreciated for your help. Have a good one...

Kate


Nov 15 '05 #6

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

Similar topics

2
by: ip4ram | last post by:
I used to work with C and have a set of libraries which allocate multi-dimensional arrays(2 and 3) with single malloc call. data_type **myarray =...
6
by: Ruben | last post by:
I'm trying to pass an array of string to a function without knowing how many strings I have beforehand. I've defined one functions as char * insert(char table,int cols, char values); out of...
16
by: rguti | last post by:
Hi, How do I create a two dimensional array? I have created a one dimensional doing this: Dim laFields As ArrayList = New ArrayList How about to do a 2 dimensional?
60
by: Peter Olcott | last post by:
I need to know how to get the solution mentioned below to work. The solution is from gbayles Jan 29 2001, 12:50 pm, link is provided below: >...
5
by: Diffident | last post by:
Hello All, I have a 2-dimensional array that I am storing as a session variable. I have no idea on how I can cast the session variable back to 2-dimensional array. Any pointers? Reference...
22
by: spam.noam | last post by:
Hello, I discovered that I needed a small change to the Python grammar. I would like to hear what you think about it. In two lines: Currently, the expression "x" is a syntax error. I suggest...
6
by: fniles | last post by:
I need to store information in a 2 dimensional array. I understand ArrayList only works for a single dimensional array, is that correct ? So, I use the 2 dimensional array like in VB6. I pass the...
8
by: per9000 | last post by:
Hi all, I have a two-dimensional array of data, f.x int's. We can imagine that the array is "really large". Now I want the data in it and store this in a one-dimensional array. The obvious...
272
by: Peter Olcott | last post by:
http://groups.google.com/group/comp.lang.c++/msg/a9092f0f6c9bf13a I think that the operator() member function does not work correctly, does anyone else know how to make a template for making two...
5
by: nelly0 | last post by:
developing a program that will manipulate noise levels (measured in decibels) that is collected by car manufacturers. These noise levels are produced at seven different speeds by a maximum of six...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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...
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.