473,320 Members | 1,949 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,320 software developers and data experts.

Hashtable and "class containing arrays" as value

Dear Coders:

I have a hashtable,

Hashtable hash=new Hashtable();

and have a class, Pixels

class Pixels
{
public int[,] buf=new int[5,5];
..
..
..

}

when I set this
Pixels p=new Pixels;
p.buf[1,1]=0;
p.buf[2,2]=1;

hash[5]=p;

Pixels p2=hash[5];

!!! now all items of buf[,] are set to 1

Nov 16 '05 #1
1 1292
Hello,

I have tried this out and i am getting right result.

The code is
class Class1
{

[STAThread]
static void Main(string[] args)
{
Hashtable hash=new Hashtable();
Pixels p=new Pixels( );
p.buf[1,1]=0;
p.buf[2,2]=1;

hash[5]=p;

Pixels p2=hash[5] as Pixels;

Console.Write( p2.buf[1,1] + " " + p2.buf[2,2]);

}
}

class Pixels
{
public int[,] buf=new int[5,5];
}
"bi************@gmail.com" wrote:
Dear Coders:

I have a hashtable,

Hashtable hash=new Hashtable();

and have a class, Pixels

class Pixels
{
public int[,] buf=new int[5,5];
..
..
..

}

when I set this
Pixels p=new Pixels;
p.buf[1,1]=0;
p.buf[2,2]=1;

hash[5]=p;

Pixels p2=hash[5];

!!! now all items of buf[,] are set to 1

Nov 16 '05 #2

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

Similar topics

5
by: Sundial Services | last post by:
I recently brought an old application out of mothballs and launched it under PHP5, only to get this message: Fatal Error: Class '1' not found It was clearly somehow an /execution/ time...
3
by: janek | last post by:
I have a question: what differences are between: namespace Mary { int r = 5 ; char m ;
27
by: Abdullah Kauchali | last post by:
Hi folks, Can one rely on the order of keys inserted into an associative Javascript array? For example: var o = new Object(); o = "Adam"; o = "Eve";
6
by: Stephen Johns | last post by:
I want to have a Hashtable whose keys are strings and whose values are delegates. Well, ok, I have that: dels = new Hastable(); dels.Add( "key", new Foo1Delegate(MyFoo1) ); dels.Add( "key",...
0
by: MIGUEL | last post by:
Hi all! Be patient because what I'm going to explain all of you it's more than very strange. I've developed a webservice project that contains two classes. One of them is going to act as a...
6
by: John Nossluap | last post by:
I've got a third-party assembly dll containing an "internal" class with some public methods I would very much like to use. I understand the meaning and reason of setting the accessibility of the...
11
by: Kimmo Laine | last post by:
I'm flipping my wig here, people. I'm using classes and making each class a file. when I'm including dependet classess, I use require_once to avoid multiple declarations - yet they happen. I put...
1
by: Martin Plechsmid | last post by:
Hello, (After investigating my real problem) I've got a C# web service containing a single method: public MyBDO Test() { return null; }
4
by: Christian Joergensen | last post by:
Hello I stumpled upon this "feature" during my work tonight, and found it a bit confusing: .... class C: .... foobar = 42 .... .... <class __main__.C at 0xb7cf735c>
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.