开发者

How to debug the code in winform

开发者 https://www.devze.com 2023-01-28 21:25 出处:网络
I have a function like this in one of my classes using MFDBAnalyser; namespace PrimaryKeyChecker { public class PrimaryKeyChecker : IMFDBAnalyserPlugin

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

精彩评论

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