Re: C# Question

  • From: "Ricks Place" <OFBGMail@xxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Sun, 30 Mar 2008 14:53:08 -0400

Hi Chris:
How adept are you with C# Arrays? I ask because the format of the definition just looks wierd somehow, not looked at C# in a long time. Also, dataTable might be treading on the DataTable keyword or the array was not instantiated. If you are adept at using C# arrays I'll guess it is something I've just not encountered, assigning objects in an array. Otherwise I'll dig into the docs for Arrays and see if I can find anything.
Rick USA
----- Original Message ----- From: "Chris Hofstader" <chris.hofstader@xxxxxxxxxxx>
To: <programmingblind@xxxxxxxxxxxxx>
Sent: Sunday, March 30, 2008 2:26 PM
Subject: C# Question


Hi,

I have a class which, for purposes of illustration, I'll call MyClass.  I
want to declare a two dimensional array of this class so I can have a set of
rows and columns within.  I don't know the ultimate size of the array so I
declare it with empty brackets.

For instance:

MyArray[][] dataTable;  // This compiles without error

but, in the code, if I state:

dataTable[0][0] = new MyClass();

I get an exception about a NULL assignment when the code is executed.

I had thought that .Net arrays declared without the "fixed" keyword would
grow dynamically and that the Array type overloaded the brackets to ensure
the sort of exception I'm getting doesn't happen.

Obviously, I'm doing something quite wrong but I'm having trouble finding
examples of C# arrays of anything more complex than int or String.

Please help.

Thanks,
cdh

Chris Hofstader
CUNY, BSO, ATG, Odds and Ends
email: cdh@xxxxxxxxxxxxx
Blog: http://www.blindconfidential.blogspot.com
Skype: BlindChristian
phone: 727-896-6393



__________
View the list's information and change your settings at
//www.freelists.org/list/programmingblind


__________
View the list's information and change your settings at //www.freelists.org/list/programmingblind

Other related posts: