初級 › } expected の原因と直し方 › パターン5
} expected の原因と直し方
波括弧の対応が崩れたときに出ます。
1 class Program { 2 static void Main(string[] args) { 3 int x = 5; 4 while (x > 0) { 5 x--; 6 _ ^ 7 } 8 }
Program.cs(8,2): error CS1513: } expected
空欄を埋めてビルドを通す
while文でも同様です。ファイル末尾まで読んでから対応の崩れに気づきます。
次の問題