![](/img/trans.png)
[英]Why is my debug not working in Visual Studio? (c#) [on hold]
[英]Visual Studio C# if statement not working in Debug
因此,我遇到一种奇怪的情况,即在调试时出现一条if语句,并且我发现即使EM=="M"
,我的if语句if(EM=="E")
仍在输入。我还注意到,当我单步执行代码(F11)时,我的一些代码似乎只是被跳过了。
我在VS2015和VS2017中使用C#,两个版本都存在问题。 我使用的是Framework 4.5,我已将其切换到4.6.1以为其他程序构建兼容版本。 但是切换回去并没有改变任何东西...
public static string EM = "";
Database db = doc.Database;
//db.measureunits is 0 or 1
if (db.measureunits == 1) // english
{
EM = "E";
}
else // metric
{
EM = "M";
}
try
{
if (EM == "E") //If english
{ <-- Breakpoint STOPS Here EM is equal to "M" at this point, which shouldn't allow the break point to be hit, since EM("M")!="E"
topText.TextString = rad + "\" minimum bend radius";
}
if (EM == "M") //Metric
{ <-- Breakpoint never stops Here
topText.TextString = Convert.ToString(Math.Round((Convert.ToDouble(rad)) * 0.3048, 2)) + "\" minimum bend radius";
}
}
catch (IOException e)
{
// Extract some information from this exception, and then
// throw it to the parent method.
if (e.Source != null)
System.Windows.Forms.MessageBox.Show($"IOException source: {0}", e.Source);
throw;
}
如果其他人知道此问题或知道我可能在做错什么,将不胜感激。
以下变通办法可能会有所帮助
删除bin和obj文件夹,然后重新构建。
重新启动Visual Studio或PC
一些想法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.