Welcome to Dream.In.Code
Getting C# Help is Easy!

Join 136,083 C# Programmers for FREE! Get instant access to thousands of C# experts, tutorials, code snippets, and more! There are 1,512 people online right now. Registration is fast and FREE... Join Now!




class Dictionary

 
Reply to this topicStart new topic

class Dictionary

madsiro
20 Apr, 2008 - 11:56 AM
Post #1

New D.I.C Head
*

Joined: 20 Apr, 2008
Posts: 1

Hi, I'm programming in C #, and I have a question about the class dictionary, I know that this work as a hash table, but I would like to know how that hash function uses (or which is the one that could use), and that size is its table, here is an example of Dictionary, and here is my question.
CODE

private static Dictionary<string, double> PrepareFrequency(string[] words)
{
    Dictionary<string, double> table = new Dictionary<string, double>();

    foreach (string word in words)
    {
        if (table.ContainsKey(word))
            table[word]++;
        else
            table.Add(word, 1);
    }

    return table;
}

Thanks for your attention.
User is offlineProfile CardPM
+Quote Post

zakary
RE: Class Dictionary
21 Apr, 2008 - 04:12 AM
Post #2

D.I.C Regular
Group Icon

Joined: 15 Feb, 2005
Posts: 404



Thanked: 6 times
Dream Kudos: 175
My Contributions
try it like this.
csharp

private static Dictionary<string, double> PrepareFrequency(string[] words)
{
Dictionary<string, double> table = new Dictionary<string, double>();

foreach (string word in words)
{
if (!table.ContainsKey(word))
table.Add(word, 1);
}

return table;
}

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/1/08 07:53PM

Live C# Help!

C# Tutorials

Reference Sheets

C# Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month