Click here to Skip to main content
15,867,704 members
Home / Discussions / C#
   

C#

 
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
subeditorPete 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 
QuestionProblem with MdiParent-MdiChildren forms Pin
Nine_31-May-09 20:38
Nine_31-May-09 20:38 
AnswerRe: Problem with MdiParent-MdiChildren forms Pin
dan!sh 31-May-09 21:08
professional dan!sh 31-May-09 21:08 
GeneralRe: Problem with MdiParent-MdiChildren forms Pin
Nine_31-May-09 21:12
Nine_31-May-09 21:12 
GeneralRe: Problem with MdiParent-MdiChildren forms Pin
dan!sh 31-May-09 21:23
professional dan!sh 31-May-09 21:23 
GeneralRe: Problem with MdiParent-MdiChildren forms Pin
Nine_31-May-09 21:29
Nine_31-May-09 21:29 
QuestionHow to delete the URL from cache entry in c#? Pin
svt gdwl31-May-09 20:31
svt gdwl31-May-09 20:31 
QuestionDataGridView Pin
Yathish hatter31-May-09 20:19
Yathish hatter31-May-09 20:19 
AnswerRe: DataGridView Pin
Satish Pai31-May-09 20:29
Satish Pai31-May-09 20:29 
GeneralRe: DataGridView Pin
Yathish hatter1-Jun-09 18:43
Yathish hatter1-Jun-09 18:43 
Questionfacing problem with C# ODP.Net API(Oracle.DataAccess.dll) "Open cursors exceeded" exception is occured Pin
member12345631-May-09 19:33
member12345631-May-09 19:33 
QuestionTCP Server Question *IMPORTANT* Pin
Serpendiem31-May-09 18:30
Serpendiem31-May-09 18:30 
AnswerRe: TCP Server Question *IMPORTANT* Pin
Jimmanuel1-Jun-09 2:45
Jimmanuel1-Jun-09 2:45 
Question[SOLVED] Future or past date time Pin
CodingLover31-May-09 18:02
CodingLover31-May-09 18:02 
AnswerRe: Future or past date time Pin
CodingLover31-May-09 18:05
CodingLover31-May-09 18:05 
QuestionBelow idea how to be realized in C#? Pin
mctramp16831-May-09 17:08
mctramp16831-May-09 17:08 
AnswerRe: Below idea how to be realized in C#? Pin
Christian Graus31-May-09 19:25
protectorChristian Graus31-May-09 19:25 

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.