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

C#

 
AnswerRe: ExpandoObject and Serialization of Anonymous Types ? Pin
Eddy Vluggen7-Mar-14 6:49
professionalEddy Vluggen7-Mar-14 6:49 
GeneralRe: ExpandoObject and Serialization of Anonymous Types ? Pin
BillWoodruff7-Mar-14 14:11
professionalBillWoodruff7-Mar-14 14:11 
GeneralRe: ExpandoObject and Serialization of Anonymous Types ? Pin
Eddy Vluggen7-Mar-14 23:26
professionalEddy Vluggen7-Mar-14 23:26 
QuestionSystem.ArgumentOutOfRangeException: Index was out of range Pin
computerpublic6-Mar-14 5:34
computerpublic6-Mar-14 5:34 
AnswerRe: System.ArgumentOutOfRangeException: Index was out of range Pin
Richard Andrew x646-Mar-14 5:42
professionalRichard Andrew x646-Mar-14 5:42 
GeneralRe: System.ArgumentOutOfRangeException: Index was out of range Pin
computerpublic6-Mar-14 5:48
computerpublic6-Mar-14 5:48 
GeneralRe: System.ArgumentOutOfRangeException: Index was out of range Pin
Richard Andrew x646-Mar-14 5:50
professionalRichard Andrew x646-Mar-14 5:50 
AnswerRe: System.ArgumentOutOfRangeException: Index was out of range Pin
Richard Deeming6-Mar-14 5:50
mveRichard Deeming6-Mar-14 5:50 
You're incrementing the count variable within the loop, and then trying to access the item at the new incremented index without checking whether it's in range. Once the count is out of range, the indexer will throw an IndexOutOfRangeException.

Add a test to the start of each if block to ensure that the index is still in range:
C#
if (count < bits.Length - 1 && bits[count] == false && bits[count + 1] == true)
    count++;

if (count < bits.Length - 1 && bits[count] == false && bits[count + 1] == false)
    count++;

if (count < bits.Length - 1 && bits[count] == true && bits[count + 1] == true)
    count++;

if (count < bits.Length - 1 && bits[count] == true && bits[count + 1] == false)
    count++;




"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer


GeneralRe: System.ArgumentOutOfRangeException: Index was out of range Pin
computerpublic6-Mar-14 6:13
computerpublic6-Mar-14 6:13 
GeneralRe: System.ArgumentOutOfRangeException: Index was out of range Pin
Richard Deeming6-Mar-14 6:47
mveRichard Deeming6-Mar-14 6:47 
GeneralRe: System.ArgumentOutOfRangeException: Index was out of range Pin
computerpublic6-Mar-14 7:44
computerpublic6-Mar-14 7:44 
AnswerRe: System.ArgumentOutOfRangeException: Index was out of range Pin
BobJanova6-Mar-14 7:04
BobJanova6-Mar-14 7:04 
GeneralRe: System.ArgumentOutOfRangeException: Index was out of range Pin
computerpublic6-Mar-14 7:47
computerpublic6-Mar-14 7:47 
GeneralRe: System.ArgumentOutOfRangeException: Index was out of range Pin
computerpublic6-Mar-14 7:49
computerpublic6-Mar-14 7:49 
GeneralRe: System.ArgumentOutOfRangeException: Index was out of range Pin
Richard Deeming6-Mar-14 8:06
mveRichard Deeming6-Mar-14 8:06 
GeneralRe: System.ArgumentOutOfRangeException: Index was out of range Pin
BobJanova6-Mar-14 23:05
BobJanova6-Mar-14 23:05 
Questionupdate command in sqladapter Pin
Moneyzz Sharma6-Mar-14 4:04
Moneyzz Sharma6-Mar-14 4:04 
AnswerRe: update command in sqladapter Pin
OriginalGriff6-Mar-14 4:39
mveOriginalGriff6-Mar-14 4:39 
SuggestionRe: update command in sqladapter Pin
Richard Deeming6-Mar-14 5:05
mveRichard Deeming6-Mar-14 5:05 
GeneralRe: update command in sqladapter Pin
OriginalGriff6-Mar-14 5:10
mveOriginalGriff6-Mar-14 5:10 
QuestionRe: update command in sqladapter Pin
Moneyzz Sharma6-Mar-14 5:35
Moneyzz Sharma6-Mar-14 5:35 
AnswerRe: update command in sqladapter Pin
OriginalGriff6-Mar-14 6:29
mveOriginalGriff6-Mar-14 6:29 
GeneralRe: update command in sqladapter Pin
Moneyzz Sharma6-Mar-14 8:14
Moneyzz Sharma6-Mar-14 8:14 
GeneralRe: update command in sqladapter Pin
OriginalGriff6-Mar-14 8:27
mveOriginalGriff6-Mar-14 8:27 
QuestionTranslating an "error event" to a managed exception Pin
Bernhard Hiller5-Mar-14 4:17
Bernhard Hiller5-Mar-14 4:17 

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.