开发者

How to debug the code in winform

I have a function like this in one of my classes

using MFDBAnalyser;

namespace PrimaryKeyChecker
{
    public class PrimaryKeyChecker : IMFDBAnalyserPlugin
    {
        public string RunAnalysis(string ConnectionString)
        {
            return "Srivastava";
        }
    }
}

and when I call the RunAnalysis(string ConnectionString) method in another class like this

namespace MFDBAnalyser
{
    public interface IMFDBAnalyserPlugin
    {
        string RunAnalysis(string ConnectionString);
    }
}

Then how can 开发者_如何学运维I check that the RunAnalysis is whether returning Srivastava or not....


You could add System.Diagnostic.Debugger.Break(), when you will run your application in Visual studio the debugger will stop at that line. You will then be sure that "Srivastava" is returned.

using MFDBAnalyser;

namespace PrimaryKeyChecker
{
    public class PrimaryKeyChecker : IMFDBAnalyserPlugin
    {
        public string RunAnalysis(string ConnectionString)
        {
            System.Diagnostic.Debugger.Break() 
            return "Srivastava";
        }
    }
}


public void Test()
{
    IMFDBAnalyserPlugin myClass = new PrimaryKeyChecker();
    var result = myClass.RunAnalysis("you connection string");
}

The result should be equal to "Srivastava"


Your problem is that RunAnalysis it within an interface.

Interfaces are merely provide a definition - in this case what RunAnalysis should look like in a class that implements the interface (IMFDBAnalyserPlugin)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜