C# Visual Studio 2010 Hashtable

  • (2 Pages)
  • +
  • 1
  • 2

16 Replies - 3148 Views - Last Post: 16 August 2012 - 10:45 AM Rate Topic: -----

#1 clarisaduta  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 16-August 12

C# Visual Studio 2010 Hashtable

Posted 16 August 2012 - 06:36 AM

Hi all,

So im trying to develop a small software that modifies bad and offensive words in texts. I have a attached my small dictionary but basically i want the user to have 3 options of replacements,(Euphemisms, Asterisk1, Asterisk2) for ex:
"cock" = "penis"(Replacement1, Euphemism); "c*ck"(Replacement2, Replace a vowel); and "****"(Replacement3, Replace the whole word)
"pussy" = "vagina"; "p*ssy"; and "******". and so on.
I tried to to it with regex but heard that hashtable would be better, except i dont know how to do that. bare in mind that im very new in programming. Any help would be much appreciated.

Thanks,
ClaraAttached File  Word.doc (89K)
Number of downloads: 45

Is This A Good Question/Topic? 0
  • +

Replies To: C# Visual Studio 2010 Hashtable

#2 MrShoes  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 313
  • View blog
  • Posts: 490
  • Joined: 13-June 12

Re: C# Visual Studio 2010 Hashtable

Posted 16 August 2012 - 06:47 AM

Hopefully this will get you started. You could also take a look at the Hashtable class on MSDN.

Why are there 3 different replacement options? Does the user select which replacement option they want?

It's worth noting that often, when a Hashtable is used, a Dictionary<T> can be better, due mostly to content-access type safety.
Was This Post Helpful? 0
  • +
  • -

#3 clarisaduta  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 16-August 12

Re: C# Visual Studio 2010 Hashtable

Posted 16 August 2012 - 06:57 AM

Thanks, i'll check out the links.

yes, the users should be able to choose which replacement they want.
Was This Post Helpful? 0
  • +
  • -

#4 MrShoes  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 313
  • View blog
  • Posts: 490
  • Joined: 13-June 12

Re: C# Visual Studio 2010 Hashtable

Posted 16 August 2012 - 07:04 AM

Have you considered the use of a DataSet? It might be more fitting for your needs.
Was This Post Helpful? 0
  • +
  • -

#5 clarisaduta  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 16-August 12

Re: C# Visual Studio 2010 Hashtable

Posted 16 August 2012 - 07:06 AM

plus

if i do this

hashtable.Add("cock", "penis", "c*ck", "****"); it says No overload for method 'Add' takes 4 arguments :(
Was This Post Helpful? 0
  • +
  • -

#6 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6075
  • View blog
  • Posts: 23,543
  • Joined: 23-August 08

Re: C# Visual Studio 2010 Hashtable

Posted 16 August 2012 - 07:15 AM

Read the manual! Notice the number of arguments and what they are.

Your second argument will need to be some sort of class or struct that holds the possible options for the keyword. You create an instance of that object and add it to the Hashtable with the key as the first argument.
Was This Post Helpful? 0
  • +
  • -

#7 clarisaduta  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 16-August 12

Re: C# Visual Studio 2010 Hashtable

Posted 16 August 2012 - 07:38 AM

I read the manual, but dont know how to add a second or a third argument to the hashtable. JackofAlltrades Can you help ?
Was This Post Helpful? 0
  • +
  • -

#8 Curtis Rutland  Icon User is online

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4526
  • View blog
  • Posts: 7,895
  • Joined: 08-June 10

Re: C# Visual Studio 2010 Hashtable

Posted 16 August 2012 - 07:57 AM

The point of reading the manual was to see that you don't add using four arguments. You have to add things in pairs. One (unique) key, one (not-necessarily-unique) value.
Was This Post Helpful? 0
  • +
  • -

#9 clarisaduta  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 16-August 12

Re: C# Visual Studio 2010 Hashtable

Posted 16 August 2012 - 08:02 AM

So what do you think the solution is then ?
Was This Post Helpful? 0
  • +
  • -

#10 Curtis Rutland  Icon User is online

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4526
  • View blog
  • Posts: 7,895
  • Joined: 08-June 10

Re: C# Visual Studio 2010 Hashtable

Posted 16 August 2012 - 08:04 AM

I guess you'd have to rephrase the question. Why do you think you need to add four parameters at a time? What are you actually trying to do?
Was This Post Helpful? 0
  • +
  • -

#11 clarisaduta  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 16-August 12

Re: C# Visual Studio 2010 Hashtable

Posted 16 August 2012 - 08:13 AM

I said why at the beginning of this convo. Im trying to develop a small software that modifies bad and offensive words in texts. I have a attached my small dictionary but basically what i want is the user to have 3 options of replacements,(Euphemisms, Asterisk1, Asterisk2) for ex:
"cock" = "penis"(Replacement1, Euphemism); "c*ck"(Replacement2, Replace a vowel); and "****"(Replacement3, Replace the whole word)
"pussy" = "vagina"; "p*ssy"; and "******". and so on.
I tried to it with regex but heard that hashtable would be better, except now i know that you cant add more than one argument.

Attached File(s)

  • Attached File  Word.doc (89K)
    Number of downloads: 27

Was This Post Helpful? 0
  • +
  • -

#12 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6075
  • View blog
  • Posts: 23,543
  • Joined: 23-August 08

Re: C# Visual Studio 2010 Hashtable

Posted 16 August 2012 - 08:19 AM

Pretty sure I answered the question in my post.

Do you KNOW how to program in C#? Or at all?
Was This Post Helpful? 0
  • +
  • -

#13 clarisaduta  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 16-August 12

Re: C# Visual Studio 2010 Hashtable

Posted 16 August 2012 - 08:28 AM

No I dont KNOW. I said that im just starting to learn how to program so what u said is pretty confusing for me. but thanks for the info. I'll ask a friend to explain it in a beginners&dumb way.
Was This Post Helpful? 0
  • +
  • -

#14 Curtis Rutland  Icon User is online

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4526
  • View blog
  • Posts: 7,895
  • Joined: 08-June 10

Re: C# Visual Studio 2010 Hashtable

Posted 16 August 2012 - 08:32 AM

I'm sorry, but you keep going in circles. I don't understand what you think you gain by trying to use four parameters at once? What do you think that should do?

Here's the simplest explanation of a hash-table I have. It's a sequence of key-value pairs. That's it. You add things in pairs (always in pairs). Keys, and values associated with that key.

That's all a hashtable does. It stores pairs of things. Which would be helpful to you, maybe. But you can't try to add four things at once. You have to add things in pairs. Pairs that relate to each other. You could make the profane string a key, and the clean string a value. But you can't relate multiple values to one key. So you can't add four things at once.
Was This Post Helpful? 0
  • +
  • -

#15 clarisaduta  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 16-August 12

Re: C# Visual Studio 2010 Hashtable

Posted 16 August 2012 - 08:44 AM

Ok. Thank you Curtis, now I understand. What i am trying to do is to have those 3 options of replacement that the users can select, that is all. I did the replacements with Regex (one by one) and it works just fine, but someone suggested that I should use Hashtable, obviously he did not know that you can't add more than one argument. That is why I was confused.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2