Re: Search Array
Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance
Stefan L wrote:
Jonathan Wood schrieb:
I've created a simple array of unsorted strings.
Is there a SIMPLE way to see if the array contains a string while
ignoring case, without writing my own loop?
I don't mind writing my own loop but if there's already something to
do this, I'd like to find it. I've found all sorts of complex stuff
but nothing to perform this rather trivial task.
> If it's just about avoiding to write the code, you could use:
>
> string[] myStrings = { "A", "B", "C" };
> string stringToFind = "B";
>
> if (Array.IndexOf(myStrings, stringToFind) >= 0)
> doSomething();
>
> It's oldschool and doesn't look as cool as LINQ and Lambda-Expressions,
> but it's far easier to keep in mind...
I believe it is part of old school to note such things
as "ignoring case" !
Arne
.
Relevant Pages
- Re: Search Array
... Is there a SIMPLE way to see if the array contains a string while ignoring case, without writing my own loop? ... I don't mind writing my own loop but if there's already something to do this, ... (microsoft.public.dotnet.languages.csharp) - Re: Search Array
... Is there a SIMPLE way to see if the array contains a string while ignoring case, without writing my own loop? ... I don't mind writing my own loop but if there's already something to do this, ... I've found all sorts of complex stuff but nothing to perform this rather trivial task. ... (microsoft.public.dotnet.languages.csharp) - Re: Problem with a script
... a loop there becomes impractical. ... You still have them as uniquely named array indexes... ... writing the code twice will only ... reading your entire code and parsing it in their head, ... (comp.lang.php) - Re: Problem with a script
... Okay, so variables have unique labels, that doesn't mean they still couldn't be handled in a loop. ... You still have them as uniquely named array indexes... ... I believe that for the new guy this code would be readable, and identifying problems should really not be any more difficult with this, plus I think that it actually might save some time to write the actual code from the beginnig, even though it's not at it's final stage, instead of first writing everything spread out, and then rewriting the same code again cleaned. ... If you expect a person to spend an hour reading your entire code and parsing it in their head, you wont get any help and have to solve the problem by yourself. ... (comp.lang.php) - Re: FOR Loop slows down with each iteration?
... >>> P.S. Don't write to a file inside a triple for loop. ... Writing to disk is generally>> done asynchronously by the operating system when the program requests to>> write one or more pages; pages were traditionally 4 K byte, but these>> days are more likely to be 16 K byte. ... All else being equal, the larger>> the more pages of data you can submit to write at one time, the less>> overhead will be involved, but only if those buffers can be pre-allocated>> ... > I cannot pre- allocate an array for the data that is being written as the> number of data is unknown...it is basically iterating through arrays and> extracting relevant data... ... (comp.soft-sys.matlab) |
|