简体   繁体   English

如果在Visual Studio和C#中,我可以在内联中设置断点吗?

[英]Can I set a breakpoint in an inline if in Visual Studio and C#?

Can I set a breakpoint like below (the asterisk symbolises the breakpoint dot)? 我可以设置如下的断点(星号表示断点)吗?

    var x = ifThis ?
*       This() :
        That() ;

Environment is C# and Visual Studio 2015. 环境是C#和Visual Studio 2015。

( I just told a colleague that I was possible but seem to stand corrected ) 我刚告诉一位同事,我有可能,但似乎有所纠正

You can only place the breakpoint in the whole line. 您只能将断点放在整行中。

However, you can: 但是,您可以:

  1. Press F11 while debugging to enter the line and see which function was hit; 在调试时按F11进入该行并查看被击中的功能;

  2. Add a conditional breakpoint so it will only break in the specified conditional; 添加条件断点,使其仅在指定的条件中断开; This is the closest of what you want, and have no practical difference on setting the break point on only one part of the expression, other than the full line being marked in VS. 这是你想要的最接近的,除了在VS中标记的整行之外,在表达式的一部分上设置断点没有实际区别。

To add a conditional breakpoint, first set the breakpoint, then right click the red dot on the left -> "Condition..." 要添加条件断点,首先设置断点,然后右键单击左侧的红点 - >“条件...”

Visual Studio sees this as a single line and the breakpoint will show as being on all 3 lines. Visual Studio将此视为单行,断点将显示为在所有3行上。 You cannot set it on a single line in an inline if statement. 您不能在内联if语句中将其设置在单行上。

Sorry! 抱歉!

Karl and Andre are right. 卡尔和安德烈是对的。 In VS 2015 you can only use the conditional Breakpoint and then step into with F11. 在VS 2015中,您只能使用条件断点,然后进入F11。

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Visual Studio中的C#通用类/方法上设置函数断点? - Set a Function Breakpoint on a C# Generic Class/Method in Visual Studio? 如何在Visual Studio 2013中的C#结构字段上设置断点 - How to set a breakpoint on a C# structure field in Visual Studio 2013 Visual Studio 2012 / C#中断了代码执行,没有设置断点 - Visual Studio 2012/C# breaks code execution, no breakpoint set 访问成员变量时在Visual Studio中设置断点C# - Set breakpoint in Visual Studio when a member variable is accessed C# Microsoft Visual Studio 2012无法在c#文件中设置断点 - Microsoft Visual Studio 2012 cannot set breakpoint in c# file 当 Visual Studio 调试器评估值时,我可以让我的 C# 代码在断点处停止吗? - Can I make my C# code stop at breakpoint when Visual Studio debugger is evaluating the value? C#/ Visual Studio-除非有断点,否则对象为null - C# / Visual Studio - Object is null unless I have a Breakpoint 为什么Visual Studio无法在这个简单的C#属性上设置条件断点? - Why does Visual Studio fail to set a conditional breakpoint on this simple C# property? 有没有办法在C#/ Visual Studio的断点上睡觉? - Any way to sleep on a breakpoint in C# / Visual Studio? Visual Studio C#调试器 - 当前不会遇到断点 - Visual Studio C# debugger - the breakpoint will not currently be hit
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM