Click here to Skip to main content
15,913,773 members
Home / Discussions / C#
   

C#

 
GeneralRe: ObservableCollection Constructor Pin
Michael Sync11-Jan-09 7:21
Michael Sync11-Jan-09 7:21 
GeneralRe: ObservableCollection Constructor Pin
S. Senthil Kumar11-Jan-09 8:24
S. Senthil Kumar11-Jan-09 8:24 
GeneralRe: ObservableCollection Constructor Pin
Michael Sync11-Jan-09 8:45
Michael Sync11-Jan-09 8:45 
GeneralRe: ObservableCollection Constructor Pin
S. Senthil Kumar11-Jan-09 8:58
S. Senthil Kumar11-Jan-09 8:58 
AnswerRe: ObservableCollection Constructor Pin
User 665811-Jan-09 7:51
User 665811-Jan-09 7:51 
GeneralRe: ObservableCollection Constructor Pin
Michael Sync11-Jan-09 8:45
Michael Sync11-Jan-09 8:45 
GeneralRe: ObservableCollection Constructor Pin
Michael Sync12-Jan-09 4:49
Michael Sync12-Jan-09 4:49 
QuestionList<T>.AddRange and ArgumentException? Pin
User 665811-Jan-09 4:05
User 665811-Jan-09 4:05 
Hi everyone,

I'm experiencing a strange exception in the List<T>.AddRange[^] method.
Sometimes (maybe in 1 out of 100 runs with the same data) I get a System.ArgumentException inside AddRange that the destination array is not large enough for the collection. Here's what I'm doing:

if (itemsToAdd > 0)
{
   existingItems.AddRange(itemsToAdd); // boom
   itemsToAdd.Clear();
}


Now MSDN clearly states:

If the new Count (the current Count plus the size of the collection) will be greater than Capacity, the capacity of the List<(Of <(T>)>) is increased by automatically reallocating the internal array to accommodate the new elements, and the existing elements are copied to the new array before the new elements are added.

Did anyone else experience this weird behaviour?


regards

modified 12-Sep-18 21:01pm.

AnswerRe: List&lt;T&gt;.AddRange and ArgumentException? Pin
Not Active11-Jan-09 4:16
mentorNot Active11-Jan-09 4:16 
GeneralRe: List&lt;T&gt;.AddRange and ArgumentException? Pin
User 665811-Jan-09 4:26
User 665811-Jan-09 4:26 
GeneralRe: List&lt;T&gt;.AddRange and ArgumentException? Pin
Not Active11-Jan-09 4:33
mentorNot Active11-Jan-09 4:33 
GeneralRe: List&lt;T&gt;.AddRange and ArgumentException? Pin
User 665811-Jan-09 4:52
User 665811-Jan-09 4:52 
AnswerRe: List&lt;T&gt;.AddRange and ArgumentException? Pin
Daniel Grunwald11-Jan-09 4:35
Daniel Grunwald11-Jan-09 4:35 
GeneralRe: List&lt;T&gt;.AddRange and ArgumentException? Pin
User 665811-Jan-09 4:56
User 665811-Jan-09 4:56 
GeneralRe: List&lt;T&gt;.AddRange and ArgumentException? Pin
Daniel Grunwald11-Jan-09 5:01
Daniel Grunwald11-Jan-09 5:01 
GeneralRe: List&lt;T&gt;.AddRange and ArgumentException? Pin
User 665811-Jan-09 6:48
User 665811-Jan-09 6:48 
GeneralRe: List&lt;T&gt;.AddRange and ArgumentException? Pin
Guffa11-Jan-09 7:47
Guffa11-Jan-09 7:47 
GeneralRe: List&lt;T&gt;.AddRange and ArgumentException? Pin
User 665811-Jan-09 8:18
User 665811-Jan-09 8:18 
QuestionCrystalDecisions.CrystalReports.Engine.PictureObject Pin
md_refay11-Jan-09 1:03
md_refay11-Jan-09 1:03 
AnswerRe: CrystalDecisions.CrystalReports.Engine.PictureObject Pin
Wendelius11-Jan-09 1:48
mentorWendelius11-Jan-09 1:48 
Question3D plot Pin
sevda2011-Jan-09 0:44
sevda2011-Jan-09 0:44 
AnswerPlease Ignore Pin
Abhijit Jana11-Jan-09 1:21
professionalAbhijit Jana11-Jan-09 1:21 
Question3Dplot Pin
sevda2010-Jan-09 23:35
sevda2010-Jan-09 23:35 
AnswerRe: 3Dplot Pin
DaveyM6910-Jan-09 23:49
professionalDaveyM6910-Jan-09 23:49 
QuestionQuestion: how to access main Form component from another class ? Pin
Mohammemd10-Jan-09 20:06
Mohammemd10-Jan-09 20:06 

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.