Click here to Skip to main content
15,887,335 members
Home / Discussions / C#
   

C#

 
GeneralRe: Arrow keys and textBox cursor Pin
Richard W Allen1-Jun-09 1:27
Richard W Allen1-Jun-09 1:27 
GeneralRe: Arrow keys and textBox cursor Pin
dan!sh 1-Jun-09 1:35
professional dan!sh 1-Jun-09 1:35 
GeneralRe: Arrow keys and textBox cursor Pin
Richard W Allen1-Jun-09 1:49
Richard W Allen1-Jun-09 1:49 
Question[Deployment] How to customize Radio button in deployment process. Pin
rockxuyenmandem31-May-09 23:16
rockxuyenmandem31-May-09 23:16 
QuestionHow to get a Unique ID ( or Network Card Mac Address) in Mobile Devices ? Pin
MehmetFurkan31-May-09 23:04
MehmetFurkan31-May-09 23:04 
AnswerRe: How to get a Unique ID ( or Network Card Mac Address) in Mobile Devices ? Pin
Rajesh Anuhya1-Jun-09 0:07
professionalRajesh Anuhya1-Jun-09 0:07 
GeneralRe: How to get a Unique ID ( or Network Card Mac Address) in Mobile Devices ? Pin
MehmetFurkan1-Jun-09 1:29
MehmetFurkan1-Jun-09 1:29 
GeneralRe: How to get a Unique ID ( or Network Card Mac Address) in Mobile Devices ? Pin
Rajesh Anuhya1-Jun-09 2:43
professionalRajesh Anuhya1-Jun-09 2:43 
Questionhi peoples... Pin
Hema Bairavan31-May-09 22:31
Hema Bairavan31-May-09 22:31 
AnswerRe: hi peoples... Pin
Simon P Stevens31-May-09 22:48
Simon P Stevens31-May-09 22:48 
GeneralRe: hi peoples... Pin
Hema Bairavan31-May-09 22:53
Hema Bairavan31-May-09 22:53 
GeneralRe: hi peoples... Pin
Simon P Stevens31-May-09 23:14
Simon P Stevens31-May-09 23:14 
GeneralRe: hi peoples... Pin
Vasudevan Deepak Kumar1-Jun-09 0:27
Vasudevan Deepak Kumar1-Jun-09 0:27 
GeneralRe: hi peoples... Pin
Pete O'Hanlon1-Jun-09 2:57
mvePete O'Hanlon1-Jun-09 2:57 
AnswerRe: hi peoples... Pin
Pete O'Hanlon1-Jun-09 4:23
mvePete O'Hanlon1-Jun-09 4:23 
Questionabout PowerCollections and C5 library Pin
Seraph_summer31-May-09 22:27
Seraph_summer31-May-09 22:27 
AnswerRe: about PowerCollections and C5 library Pin
Simon P Stevens31-May-09 22:45
Simon P Stevens31-May-09 22:45 
QuestionAuto-resize C# Datagridview Pin
Mbulelo31-May-09 22:20
Mbulelo31-May-09 22:20 
AnswerRe: Auto-resize C# Datagridview Pin
Satish Pai31-May-09 22:24
Satish Pai31-May-09 22:24 
AnswerRe: Auto-resize C# Datagridview Pin
alien viper31-May-09 22:54
alien viper31-May-09 22:54 
QuestionHow to implement observableCollection.Exist() method? Pin
Kunal Chowdhury «IN»31-May-09 21:32
professionalKunal Chowdhury «IN»31-May-09 21:32 
AnswerRe: How to implement observableCollection.Exist() method? Pin
Pete O'Hanlon31-May-09 22:16
mvePete O'Hanlon31-May-09 22:16 
QuestionRe: How to implement observableCollection.Exist() method? Pin
Kunal Chowdhury «IN»31-May-09 22:32
professionalKunal Chowdhury «IN»31-May-09 22:32 
AnswerRe: How to implement observableCollection.Exist() method? Pin
Simon P Stevens31-May-09 22:38
Simon P Stevens31-May-09 22:38 
Use reflector to take a look at how Exists is implemented on List.

It uses a method called FindIndex, which you can also look at.

It's pretty simple. It checks some preconditions and throws various argument exceptions, but the main part of the code is just a for loop calling the passed in predicate on each item.

public bool Exists(Predicate<T> match)
{
    return (this.FindIndex(match) != -1);
}

public int FindIndex(Predicate<T> match)
{
    return this.FindIndex(0, this._size, match);
}

public int FindIndex(int startIndex, Predicate<T> match)
{
    return this.FindIndex(startIndex, this._size - startIndex, match);
}

public int FindIndex(int startIndex, int count, Predicate<T> match)
{
    if (startIndex > this._size)
    {
        ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.startIndex, ExceptionResource.ArgumentOutOfRange_Index);
    }
    if ((count < 0) || (startIndex > (this._size - count)))
    {
        ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.count, ExceptionResource.ArgumentOutOfRange_Count);
    }
    if (match == null)
    {
        ThrowHelper.ThrowArgumentNullException(ExceptionArgument.match);
    }
    int num = startIndex + count;
    for (int i = startIndex; i < num; i++)
    {
        if (match(this._items[i]))
        {
            return i;
        }
    }
    return -1;
}


Simon

GeneralRe: How to implement observableCollection.Exist() method? Pin
Kunal Chowdhury «IN»31-May-09 23:53
professionalKunal Chowdhury «IN»31-May-09 23:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.