473,471 Members | 1,778 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

hashtable of objects and need to convert at runtime

2 New Member
I'm stuck with a problem where I need to convert hastable contents to a object type at runtime... below is the code..


//
Portfolio pf = GlobalVariables.portfolio;
IEnumerator pfDealsEnum = pf.getPortfolioDeals().GetEnumerator();
while (pfDealsEnum.MoveNext()){
Deal deal = (Deal)pfDealsEnum.Current;
}

I dont know why this is not converting, I used to do such things in VB.net but here in C#. this is not working.

Any help is more than welcome. Please respond asap.

Regards
Rajiv
Mar 27 '07 #1
2 1161
RedSon
5,000 Recognized Expert Expert
I'm stuck with a problem where I need to convert hastable contents to a object type at runtime... below is the code..


//
Portfolio pf = GlobalVariables.portfolio;
IEnumerator pfDealsEnum = pf.getPortfolioDeals().GetEnumerator();
while (pfDealsEnum.MoveNext()){
Deal deal = (Deal)pfDealsEnum.Current;
}

I dont know why this is not converting, I used to do such things in VB.net but here in C#. this is not working.

Any help is more than welcome. Please respond asap.

Regards
Rajiv
Are you sue that its not Current() or some other method that will return the current value of what the enumerator is pointed to? You may want to read up on your enumerators by visiting MSDN.
Mar 27 '07 #2
rajivksh
2 New Member
Are you sue that its not Current() or some other method that will return the current value of what the enumerator is pointed to? You may want to read up on your enumerators by visiting MSDN.

Thanx for the suggestion...

the issue is that the IEnumrator shud be started with
.Values of hashtable and not on the hashtable as such. I discovered that by looking at some older coding that I had done in VB.Net

The right code will be

IEnumerator pfDealsEnum = pf.getPortfolioDeals().Values.GetEnumerator();
NOT

IEnumerator pfDealsEnum = pf.getPortfolioDeals().GetEnumerator();

Thanx
Mar 28 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Cederstrom | last post by:
Hello group! :) I want to create a config/status object, that will contain a Hashtable. This object I would like to save through Serialization, but im having some trouble. My hashtable contain...
10
by: Brian | last post by:
I'm reasonably new to C#, and using a class containing a hashtable collection to feed a treeview. My problem is that I can't pull the data from the hashtable! Here's the code I have: if...
5
by: francois | last post by:
First of all I would to to apologize for resending this post again but I feel like my last post as been spoiled Here I go for my problem: Hi, I have a webservice that I am using and I would...
9
by: Oberon | last post by:
My HashTable (Global.Games) is a static collection of objects of type Game. A Game object has 8 fields (exposed as properties). The key to the HashTable is also one of these fields (GameID, of type...
1
by: oDDskOOL | last post by:
I realized today that the Hashtable.Clone only produces a shallow copy... that makes me go mad that M$ doesn't even provide a deep copy ctor for the Hashtable class ! mighty tech ducks might...
10
by: SK | last post by:
Hey, i have a hashtable, where I am adding some values. Now when I iterate through them then they start in reverse order, why is that happening and how can I get rid of it? Thanks
10
by: Q | last post by:
Hi, I'm using a hashtable to store away a bunch of numbers from my array: The Hashtable should look like: Key Value 1 01234 2 01235
15
by: Macca | last post by:
Hi, My app needs to potentially store a large number of custom objects and be able to iterate through them quickly. I was wondering which data structure would be the most efficient to do this,a...
10
by: chrisben | last post by:
Hi, Here is the scenario. I have a list of IDs and there are multiple threads trying to add/remove/read from this list. I can do in C# 1. create Hashtable hList = Hashtable.Synchronized(new...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
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.