473,569 Members | 2,522 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1306
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
4135
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 problem, because it did not appear on the first page I had linked to, all of which use the same includes. Even though it appears to be a compile-time...
3
1673
by: janek | last post by:
I have a question: what differences are between: namespace Mary { int r = 5 ; char m ;
27
11137
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
2199
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", new Foo2Delegate(MyFoo2) ); dels.Add( "key", new Foo3Delegate(MyFoo3) );
0
1237
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 SOAP header, and the other class is the main class containing all the web methods. Besides, the project contains two references pointing at two normal...
6
1824
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 class to internal. But is there any way, dirty or not, I could use this class and its methods anyway?
11
41064
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 debug_print_backtrace in the file to see how it is included, and here's the output: #0 require_once() called at #1 ...
1
10513
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
1463
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
7615
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7924
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7677
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7979
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5514
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5219
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3643
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1223
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.