Execute public String

Tag: string , class , public Author: jiangfeng1234 Date: 2011-09-11

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

Thank you in advance.

What is your development environment / language? Please add the relevant tags to your question.

Best Answer

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();

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)