Code Fix

初級The input string was not in a correct format の原因と直し方 › パターン2

The input string was not in a correct format の原因と直し方

int.Parseなどの変換メソッドに、数値として解釈できない文字列を渡したときに発生します。

 1  class Program {
 2      static void Main(string[] args) {
 3          int n = int.Parse(______);
                                 ^
 4          System.Console.WriteLine(n);
 5      }
 6  }
Unhandled exception. System.FormatException: The input string '12.5' was not in a correct format. at Program.Main(String[] args) in Program.cs:line 3

空欄を埋めてビルドを通す

広告
広告スロット(未設定)

The input string was not in a correct format の原因と直し方

このエラーの解説と類題をまとめて見る →

広告
広告スロット(未設定)