473,406 Members | 2,619 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,406 software developers and data experts.

Use of IDictionnary ??

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
Sep 11 '07 #1
1 1439
calderara wrote:
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<string, string>.
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.
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öran Andersson
_____
http://www.guffa.com
Sep 11 '07 #2

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

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.