Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
|
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 30th, 2005, 01:50 PM
Authorized User
 
Join Date: Jan 2005
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default Hashtable.ContainsValue

I want to add to the hashtable only when there is NOT a match. How do I apply NOT to the following code?


foreach(Match in Regex.Matches(string)){
  if(Hashtable.ContainsValue(Match)){
    Hashtable.Add(int++, Match.ToString());
  }
}


 
Old May 30th, 2005, 06:39 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,101
Thanks: 0
Thanked 2 Times in 2 Posts
Default

if (! Hashtable.ContainsValue(Match))

Hal Levy
I am here to help you, not do it for you.
That is, unless you hire me. I am looking for work.
 
Old May 31st, 2005, 08:20 AM
Authorized User
 
Join Date: Jan 2005
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I've already tried that. In my testing, I have two lines of data, the second line is a copy of the first. At runtime, the program shows both lines.

Also... do you know of a comprehensive online source for regular expressions?

 
Old May 31st, 2005, 09:16 AM
jminatel's Avatar
Wrox Staff
Points: 18,059, Level: 58
Points: 18,059, Level: 58 Points: 18,059, Level: 58 Points: 18,059, Level: 58
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2003
Posts: 1,906
Thanks: 62
Thanked 139 Times in 101 Posts
Default

I don't have a comprehsensive online source for Regular Expressions, but I'll be a little self-serving and suggest you look at our very comprehesive "Beginning Regular Expressions" book:
http://www.wrox.com/WileyCDA/WroxTit...764574892.html

It covers reg ex in VB.NET, C#, and many other languages and tools.

Jim Minatel
Senior Acquisitions Editor
Wiley Technology Publishing
WROX Press
Blog: http://wroxblog.typepad.com/
Jim's Book of the week: Beginning SQL
 
Old May 31st, 2005, 03:36 PM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post
Default


Quote:
quote:do you know of a comprehensive online source for regular expressions?

_____________
Mehdi.
software student.
 
Old May 31st, 2005, 07:07 PM
Registered User
 
Join Date: May 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by Scott Rider
 I want to add to the hashtable only when there is NOT a match. How do I apply NOT to the following code?


foreach(Match in Regex.Matches(string)){
if(Hashtable.ContainsValue(Match)){
    Hashtable.Add(int++, Match.ToString());
}
}
Scott,

It looks to me that you are adding the string representation of Match to the Hashtable yet you are passing the object Match to ContainsValue for comparison. So it is basically comparing an object to a string value. They will never be equal. I am not set up to test this right now, but try this,

foreach(Match in Regex.Matches(string)){
  if(!Hashtable.ContainsValue(Match.ToString())){
    Hashtable.Add(int++, Match.ToString());
  }
}

Let me know if it Works

Bilal


 
Old March 23rd, 2008, 01:49 AM
Registered User
 
Join Date: Mar 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to sre08
Default

use HashTable ContainsValue

check this

http://vb.net-informations.com/colle..._HashTable.htm

thanks.







Similar Threads
Thread Thread Starter Forum Replies Last Post
Hashtable ajit Java Basics 1 July 11th, 2006 01:25 AM
ContainsValue doesnt work demitry Generics 1 November 21st, 2005 05:29 PM
Hashtable mahulda General .NET 2 August 2nd, 2004 07:49 AM
Hashtable in C# sachin-csharp .NET Framework 2.0 0 July 28th, 2004 01:45 AM
about hashtable csc820203 C# 1 July 11th, 2004 07:44 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.