Lưu ý
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử đăng nhập hoặc thay đổi thư mục.
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử thay đổi thư mục.
Unreachable code detected
The compiler detected code that will never be executed.
Example
The following example generates CS0162:
// CS0162.cs
// compile with: /W:2
public class Program
{
public static void Main()
{
goto lab1;
{
// The following statements cannot be reached:
int i = 9; // CS0162
i++;
}
lab1:
{
}
}
}
Another common example where this error is generated is as follows:
public static class Class1
{
public static string Method1()
{
string x = "a";
switch (x)
{
case "a":
return "a";
break; // CS0162
}
return "";
}
}
The break
statement cannot be reached because it occurs after the return
statement.
The return
statement ends the enclosing case
branch.
Cộng tác với chúng tôi trên GitHub
Bạn có thể tìm thấy nguồn cho nội dung này trên GitHub, nơi bạn cũng có thể tạo và xem lại các vấn đề và yêu cầu kéo. Để biết thêm thông tin, hãy xem hướng dẫn dành cho người đóng góp của chúng tôi.