T
T
tac2012-07-05 15:40:08
Programming
tac, 2012-07-05 15:40:08

How does IndexOf work in C#?

Who knows what search algorithm IndexOf works in C#? Where can I read about this or can I see the source code for the IndexOf method in C#?

Answer the question

In order to leave comments, you need to log in

6 answer(s)
S
SychevIgor, 2012-07-06
@SychevIgor

.net is available in source code. You can google and open.

S
Seter17, 2012-07-05
@Seter17

doesn't fit ?
otherwise reflector will help you

A
Anatoly, 2012-07-05
@taliban

For me, this is the simplest algorithm, since the lines are neither sorted nor connected in any way. In sorted / linked arrays, everything is different, I think, there, depending on the structure, the method is most likely overridden.

function indexOf(neededChar)
{
    for( q = 0; q < string.length; q++ )
    {
        if( string[q] === neededChar )
        {
            return q;
        }
    }
    return -1;
}

T
tac, 2012-07-05
@tac

I think it's not so simple www.blackbeltcoder.com/Articles/algorithms/fast-text-search-with-boyer-moore

T
tac, 2012-07-05
@tac

By the way the difference between
Index = Str.IndexOf(FindString, Index);
and
Index = Str.IndexOf(FindString, Index, StringComparison.Ordinal);
is really significant on a particular task as 14.20 minutes versus 8.20, and judging by the article there is already a full optimization

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question