Intro
- env
Visual Studio 2019 Community
.net framework 4.7.2
- 解决
使用了其他语句,将想要查看的信息打印在Output
窗口。
Operation
4点:
- 输出语句必须使用
System.Diagnostics.Debug.WriteLine("22222");
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace MvcMovie.Controllers
{
public class WyjController : Controller
{
public string Index()
{
Console.WriteLine("11111");
System.Diagnostics.Debug.WriteLine("22222 " + DateTime.Now); // 会输出到 Output
return "访问成功 " + DateTime.Now;
}
}
}
- 必须打开
Output
窗口Ctrl+Alt+O
- 必须是调试而非运行,否则output中不会输出想要输出的信息。
F5
功能本质 | 快捷键 | 菜单名(中文) | 菜单名(英文) |
---|---|---|---|
调试(Debug) | F5 | 开始调试 | Start Debugging |
运行(Run) | Ctrl+F5 | 开始执行(不调试) | Start Without Debugging |
- 切换
输出
窗口显示的输出来源为调试/Debug
测试
访问规则: WyjController
中的Index
方法的访问path: /Wyj/Index
或 /Wyj/
可以看到使用System.Diagnostics.Debug.WriteLine()
输出的信息被打印。
测试成功。
Others
打印变量
是最原始最基本的Debug方案。。
其实也可以通过Debug
操作去调试/观察程序的运行细节。