Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / April 2008

Tip: Looking for answers? Try searching our database.

how looping over a dictionary by loop for

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
skneife@gmail.com - 27 Apr 2008 23:42 GMT
I need to access to a dictionary by its index like a string array.
Dictionary<string, string> tdmDx1 = new Dictionary<string, string>();
for (int item = 0; item < tdmDx1.Count; item++) {

  .... how access item by its index ???

}

Sam
Paul E Collins - 28 Apr 2008 00:09 GMT
> I need to access to a dictionary by its index like a string array.
> Dictionary<string, string> tdmDx1 = new Dictionary<string, string>();
> for (int item = 0; item < tdmDx1.Count; item++) {
>   .... how access item by its index ???

foreach (KeyValuePair<string, string> kv in tdmDx1)

Eq.
Brian Gideon - 28 Apr 2008 00:43 GMT
On Apr 27, 5:42 pm, skne...@gmail.com wrote:
> I need to access to a dictionary by its index like a string array.
> Dictionary<string, string> tdmDx1 = new Dictionary<string, string>();
[quoted text clipped - 5 lines]
>
> Sam

You can't because the Dictionary class is implemented with a hashtable
so the index doesn't make much sense.  Let me ask you this...what
would you want the index value of 0 to mean?  That might help us
determine what kind of collection best fits your needs.
Tantr Mantr - 28 Apr 2008 10:05 GMT
Sam, Not sure why you need to loop thru a dictionary using index, but have
you had a look at wintellect's power collections
(http://www.wintellect.com/PowerCollections.aspx). The OrderedDictionary
might be what you are looking for.

Cheers!

> I need to access to a dictionary by its index like a string array.
> Dictionary<string, string> tdmDx1 = new Dictionary<string, string>();
[quoted text clipped - 5 lines]
>
> Sam

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.