Click here to Skip to main content
15,917,642 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
AnswerRe: IList vs array performance observation (.NET 2.0) Pin
ricardojb20-Mar-06 9:29
ricardojb20-Mar-06 9:29 
Of course there will be a performance penalty for using a collection over an array. Even though with generics you can easily implement strongy typed collections (avoiding casting and boxing unboxing), the collections in fact use arrays. They provide you with more flexibility than an array (like you don't need to know the number of elements and they can grow as needed) but basically what it does is array operations.

There are some ways you can improve performance, if you know the number of items you can setup the MaximumLenght property of your collection.

Also, both with arrays and collections, whenever you try to access a member, the CLR will perform a bound check.

but if you access it in a for loop, where you expressely use the .Count, or .Lenght property, the compiler is smart enough to detect that and won't do bound checks with a considerable performance gain (in long running loops).

for example

suppose you have an array a and you want to iteract.

you can do it like this:

int limit = a.Lenght;

for (int i = 0; i < limit; i++)
{
}

this will do a bound check for each iteraction.

if you do

for (int i=0; i < a.Lenght; i++)
{
}

this boundcheck will not be performed.
GeneralRe: IList vs array performance observation (.NET 2.0) Pin
wout de zeeuw20-Mar-06 10:11
wout de zeeuw20-Mar-06 10:11 
GeneralRe: IList vs array performance observation (.NET 2.0) Pin
Ed.Poore24-Mar-06 8:01
Ed.Poore24-Mar-06 8:01 
GeneralRe: IList vs array performance observation (.NET 2.0) Pin
wout de zeeuw24-Mar-06 9:15
wout de zeeuw24-Mar-06 9:15 
GeneralRe: IList vs array performance observation (.NET 2.0) Pin
Ed.Poore24-Mar-06 10:57
Ed.Poore24-Mar-06 10:57 
QuestionIs this possible? Pin
Xaake19-Mar-06 10:48
Xaake19-Mar-06 10:48 
AnswerRe: Is this possible? Pin
Dave Kreskowiak19-Mar-06 12:36
mveDave Kreskowiak19-Mar-06 12:36 
GeneralRe: Is this possible? Pin
Xaake19-Mar-06 23:02
Xaake19-Mar-06 23:02 
QuestionExecuting code remotely Pin
Imtiaz Murtaza18-Mar-06 6:51
Imtiaz Murtaza18-Mar-06 6:51 
QuestionTransaction state in 3-tier architecture Pin
Sheshadrinath17-Mar-06 23:05
Sheshadrinath17-Mar-06 23:05 
AnswerRe: Transaction state in 3-tier architecture Pin
Guffa18-Mar-06 2:27
Guffa18-Mar-06 2:27 
QuestionReplace system tray clock Pin
bowlermonk17-Mar-06 7:33
bowlermonk17-Mar-06 7:33 
AnswerRe: Replace system tray clock Pin
Dave Kreskowiak17-Mar-06 9:20
mveDave Kreskowiak17-Mar-06 9:20 
GeneralRe: Replace system tray clock Pin
bowlermonk17-Mar-06 10:43
bowlermonk17-Mar-06 10:43 
GeneralRe: Replace system tray clock Pin
Dave Kreskowiak17-Mar-06 16:25
mveDave Kreskowiak17-Mar-06 16:25 
QuestionProblem getting thread to work Pin
rsw117-Mar-06 6:57
rsw117-Mar-06 6:57 
QuestionTextBox Control Pin
John L. DeVito17-Mar-06 6:17
professionalJohn L. DeVito17-Mar-06 6:17 
AnswerRe: TextBox Control Pin
Guffa17-Mar-06 6:37
Guffa17-Mar-06 6:37 
GeneralRe: TextBox Control Pin
John L. DeVito17-Mar-06 7:18
professionalJohn L. DeVito17-Mar-06 7:18 
AnswerRe: TextBox Control Pin
Office Lineman17-Mar-06 7:19
Office Lineman17-Mar-06 7:19 
AnswerRe: TextBox Control Pin
HimaBindu Vejella19-Mar-06 23:47
HimaBindu Vejella19-Mar-06 23:47 
QuestionDetect and ignore missing COM, dll, library Pin
sgub16-Mar-06 15:22
sgub16-Mar-06 15:22 
Questionsql ce Pin
sunny74716-Mar-06 9:35
sunny74716-Mar-06 9:35 
AnswerRe: sql ce Pin
Mike Dimmick18-Mar-06 11:01
Mike Dimmick18-Mar-06 11:01 
QuestionReading in data from GPS(serial Port) Pin
prashantkgupta16-Mar-06 8:59
prashantkgupta16-Mar-06 8:59 

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.