Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

ArgumentOutOfRangeException List error c#

Can someone please explain why this line does not work

dest = await GetDestinationContext(pbx.Nodes.FirstOrDefault(x => x.Id == dests[normalTsCount++]));

But this does

dest = await GetDestinationContext(pbx.Nodes.FirstOrDefault(x => x.Id == dests[normalTsCount]));
normalTsCount++;

The first line gives an ArgumentOutOfRangeException the first time it runs.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

because at

dest = await GetDestinationContext(pbx.Nodes.FirstOrDefault(x => x.Id == dests[normalTsCount++]))

the normalTsCount++ incerements each iteration over Nodes

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading