Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/285.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/visual-studio/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在visual studio 2015中逐步使用skips方法_C#_Visual Studio_Debugging_Visual Studio Debugging - Fatal编程技术网

C# 在visual studio 2015中逐步使用skips方法

C# 在visual studio 2015中逐步使用skips方法,c#,visual-studio,debugging,visual-studio-debugging,C#,Visual Studio,Debugging,Visual Studio Debugging,我想一步一步地调试我的代码,但每当我在Visual Studio 2015中单击“单步执行”选项时,调试器就会跳过我的函数方法 我的代码 _watch.Created += this.FileCreated; public void FileCreated(object sender, FileSystemEventArgs e1) { // some code } 我在\u watch.Created+=this.FileCreated上附加了一个断点然

我想一步一步地调试我的代码,但每当我在Visual Studio 2015中单击“单步执行”选项时,调试器就会跳过我的函数方法

我的代码

   _watch.Created += this.FileCreated;

   public void FileCreated(object sender, FileSystemEventArgs e1)
   {
      // some code
   }

我在
\u watch.Created+=this.FileCreated上附加了一个断点
然后我单击了单步执行选项,但调试器跳过了
FileCreated
方法。有人能告诉我如何使用这种方法吗?

_watch.Created += this.FileCreated;
public void FileCreated(object sender, FileSystemEventArgs e1)
不会触发该方法。它在调用
Created
时指定要运行的方法

你想在上面加一个断点吗

_watch.Created += this.FileCreated;
public void FileCreated(object sender, FileSystemEventArgs e1)
然后,当调用
Created
事件时,将到达断点,您可以进入该方法

评论链接:


将断点放在事件处理程序中,然后在调用事件时它将命中。通过注册到某个事件,您实际上不会调用它。当(在您的示例中)创建文件时将调用它。感谢@SeM的回复:)我是.net的新手。我会试试你的方法。你能告诉我什么是手表吗?谢谢你的回复:)。我不熟悉.net。我将断点附加到FileCreated方法,但调试器也跳过了该断点。你能告诉我什么是手表吗?@SudiptaSaha,我不知道什么是手表。你有密码!你在学习教程吗?您基本上使用的是事件和委托。有关详细信息,请查看此内容。@SudiptaSaha,乍一看,它似乎是
\u watch
类型的对象
FileSystemWatcher
。我相信当你在
FileSystemWatcher
正在监视的目录中创建一个新文件时,
FileCreated
方法将运行,你可以调试它。我浏览了一些教程,如w3school和tutorial points,以及一些其他youtube视频,但这些都不够,或者只是说是好的教程。你能推荐一个好的学习网站吗?@SudiptaSaha,试试看。运行示例,输入断点,阅读事件和委托。