开发者

Execute public String

开发者 https://www.devze.com 2023-04-07 19:45 出处:网络
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?

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

精彩评论

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

关注公众号