Helge:
Here's a C# class with a passing NUnit 2.2 test that does what I think
you need to get done.
Let me know if this helps!
Dominique
---------------------------------
using System;
using NUnit.Framework;
using System.Collections;
namespace ClassLibrary1
{
[TestFixture] public class TestArrayContainsString
{
string [] animals = {"cat", "dog", "cow"};
[Test] public void TestThatArrayContainsString()
{
Assert.IsTrue(DoesCollectionContainsWord(animals,
"dog"));
Assert.IsFalse(DoesCollectionContainsWord(animals,
"do"));
Assert.IsTrue(DoesCollectionContainsWord(animals,
"cat"));
Assert.AreEqual(3, animals.Length);
}
public bool DoesCollectionContainsWord(ICollection aCollection,
string aWord)
{
foreach (string s in aCollection)
{
if (aWord.Equals(s))
return true;
}
return false;
}
}
}
On Wed, 26 Jan 2005 07:26:56 -0800 (PST), Dwayne Hope <[EMAIL PROTECTED]> wrote:
>
> could you check for "in " and " in"?
>
> Dwayne
>
> Helge Thomas Hellerud <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I have a string array with words. How can I check if a specific word exists
> in the array?
>
> The problem with myArray.IndexOf(myArray, word) is that it returns > 0 if
> the parameter word is a part of an element in the array (i.e. the word "in"
> matches "invite"). I want to check if only the WHOLE word exists, not a part
> of it.
>
> Helge
>
> ---------------------------------
> Yahoo! Groups Links
>
> To visit your group on the web, go to:
> http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/
>
> To unsubscribe from this group, send an email to:
> [EMAIL PROTECTED]
>
> Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
>
> [Non-text portions of this message have been removed]
>
>
> Yahoo! Groups Links
>
>
>
>
>
--
----------------------------------------------------------
dom.website = http://www.binaryshift.com
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/