开发者

Execute public String

I have a public class EmailHelp. In this class there is a public String called doIt. How do i execute this public String DoIt from within let´s say a onClick event?

public class EmailHelp{
         -----
           public String DoIt {
              ------

public void crxExecute开发者_运维问答 () {
          execute DoIt
            finish();

Thank you in advance.


Assuming that "DoIt" is not a static method, you'd need to create an instance of the EmailHelp class, and call that method:

public void Button_OnClick(object sender, EventArgs e)
{
    var emailHelper = new EmailHelp();
    emailHelper.DoIt();
}

The fact that it's not obvious that you need to instantiate EmailHelper may indicate that the method should in fact be a static one. If it were a static method, calling it would look like this:

public void Button_OnClick(object sender, EventArgs e)
{
    EmailHelp.DoIt();
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜