仅在代码实际运行时才会发生运行时错误。这些是最困难的-导致程序崩溃和代码中的错误,难以跟踪。
一个示例可能正在尝试将字符串“ hello”转换为整数:
string helloWorld = "hello";int willThrowRuntimeError = Convert.ToInt32(helloWorld);
编译器可能不会将此视为问题,但是在运行时将引发错误。
编译器错误是由于代码不正确所致,其中,编译器会引发错误,以警告您某些无法编译的内容,因此无法运行。
编译器错误的示例为:
int = "this is not an int";
希望能有所帮助。



