I 객체가 선언과 같이예기치 않은 결과가
private void LabelScan(System.IO.BinaryWriter OutputFile, bool IsLabelScan)
{
if (char.IsLetter(SourceProgram[CurrentNdx]))
{
if (IsLabelScan) LabelTable.Add(GetLabelName(), AsLength);
while (SourceProgram[CurrentNdx] != '\n')
CurrentNdx++;
CurrentNdx++;
return;
}
EatWhiteSpaces();
ReadMneumonic(OutputFile, IsLabelScan);
}
그러나 내가 실행에 오류가 : 나는 아래의 코드를 사용하여 몇 가지 물건을 구문 분석하려고 기본적으로
private string SourceProgram;
:
- SourceProgram[CurrentNdx]
'SourceProgram[CurrentNdx]' threw an exception of
type 'System.IndexOutOfRangeException' char {System.IndexOutOfRangeException}
- base {"Index was outside the bounds of the array."}
System.SystemException {System.IndexOutOfRangeException}
그리고 CurrentNdx
의 값은 46
무엇이 잘못 되었습니까? 문자열 변수 SourceProgram
이 length < 46
입니까?
예인 경우이 코드를 수정하는 방법은 무엇입니까?
여기서 'CurrentNdx'를 재설정 하시겠습니까? 그리고 예 - 문자열은 47 자 미만인 것으로 보입니다. – BrokenGlass
"문자열 변수 ... <46입니까?" 디버거에서 볼 수 있어야합니다. –
@ Lasse V. Karlsen :: 그것은 범위를 벗어난 것이 명백하지 않습니다. @BrokenGlass :: 나는 CurrentNdx를 파일로 읽는 데 사용하기 때문에 재설정 할 수 없습니다. 계속 증가해야합니다. – Sadique