Use of IDictionnary ??

G

Guest

Dear all,

I have a set of measure named and values that need to be reade and write.
fro that I was thinking to use the IDictionnary object and use this
measureName/values key pairs.

In other words i should get the following list of pairs:

System.Collections.IDictionary m_SysValue = null;

m_SysValue.Add("TotalLength", "0");
m_SysValue.Add("QualityLength", "0");
m_SysValue.Add("QualityStartAt", "0");
m_SysValue.Add("Status", "0");

Then from an other class I should be able to read those pairs and update
there values. The update object is then pass back to the initial class. AS a
result I should get :

m_SysValue.Add("TotalLength", "1250");
m_SysValue.Add("QualityLength", "1250");
m_SysValue.Add("QualityStartAt", "12");
m_SysValue.Add("Status", "3);

When I get this values update, I read them back again and I should read the
name of each key ( which correspond to a database column) and then each
value to be store to proper field.

First of all, does the sue of IDictionnary can be use in that way ?
If yes how can I do this ?

thnaks for help
regards
serge
 
G

Guest

calderara said:
Dear all,

I have a set of measure named and values that need to be reade and write.
fro that I was thinking to use the IDictionnary object and use this
measureName/values key pairs.

In other words i should get the following list of pairs:

System.Collections.IDictionary m_SysValue = null;

m_SysValue.Add("TotalLength", "0");
m_SysValue.Add("QualityLength", "0");
m_SysValue.Add("QualityStartAt", "0");
m_SysValue.Add("Status", "0");

There are two problems with this code.

1. You haven't created any collection, so there is nothing to add the
items to.

2. IDictionary is an interface, not a class, so you can't create
instances of it. You have to use an actual class, like
Dictionary said:
Then from an other class I should be able to read those pairs and update
there values. The update object is then pass back to the initial class. AS a
result I should get :

m_SysValue.Add("TotalLength", "1250");
m_SysValue.Add("QualityLength", "1250");
m_SysValue.Add("QualityStartAt", "12");
m_SysValue.Add("Status", "3);

You don't add the items again, you just set the values:

m_SysValue["TotalLength"] = "1250";
m_SysValue["QualityLength"] = "1250";
m_SysValue["QualityStartAt"] = "12";
m_SysValue["Status"] = "3";
When I get this values update, I read them back again

As you send a reference to the object to the method, the values are
changed directly in the original collection. There is no need to send
anything back.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top