c# - Visual Studio Code 在 C# 中不会出现范围错误
问题描述
我正在使用 VS Code 在 C# 中学习和测试范围。但令我惊讶的是,VS Code 没有出现关于变量“消息”不在所需范围内的警告/错误。这是文件:
using System;
public class TestScope
{
public static void Main()
{
int score = 100;
if (score >= 50)
string message = "Good score"; // Declared in if statement
Console.WriteLine(message); // Variable unavailable
}
}
我安装了 Microsoft 的扩展 C# v1.17.1,文件被 VS Code 正确识别。我徘徊是我错过了一些扩展还是没有正确设置。有什么帮助吗?
解决方案
推荐阅读
- php - Laravel,如果请求不为空,则检查条件
- r - 如何为ggplot2中的每个条分别调整值位置?
- azure - 确定在 Azure Log Analytics 工作区上设置的保留期
- python - 将 selenium 驱动程序连接到 CEF 桌面应用程序
- python - 自定义 Keras 层因功能性 API 而失败
- javascript - React js数组中的警告
- java - 用户登录时登录和将用户信息读入文本字段的问题
- android - 在使用 RX 和改造 Android 时处理 PDF 响应
- java - JavaFx - 如果值都相同,如何获取按钮数组索引
- kotlin-native - Tensorflow Kotlin/Native 在'中找不到'main'
' 包裹