Passing class string to a form label

Cannot convert method group to non-delegate type string.

Page 1 of 1

2 Replies - 7810 Views - Last Post: 22 February 2009 - 01:38 PM Rate Topic: -----

#1 gregkearney  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 22-February 09

Passing class string to a form label

Post icon  Posted 22 February 2009 - 01:24 PM

private void button2_Click(object sender, EventArgs e)
{
if (label1.Text == "Hi Greg")
{
Testing g = new Testing();
label1.Text = g.gregory; //Cannot covert method group 'gregory' to non-delegate type 'string'.
}
else
{
label1.Text="Better Luck Next Time";
}

}

public class Testing
{
string name = string.Empty;
public string gregory()
{
name = "GK";
return name;
}


}

Is This A Good Question/Topic? 0
  • +

Replies To: Passing class string to a form label

#2 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 4421
  • View blog
  • Posts: 12,289
  • Joined: 18-April 07

Re: Passing class string to a form label

Posted 22 February 2009 - 01:28 PM

Don't forget your parenthesis!... label1.Text = g.gregory(); You got to tell it that it is a method after all. :)
Was This Post Helpful? 0
  • +
  • -

#3 gregkearney  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 22-February 09

Re: Passing class string to a form label

Posted 22 February 2009 - 01:38 PM

View PostMartyr2, on 22 Feb, 2009 - 12:28 PM, said:

Don't forget your parenthesis!... label1.Text = g.gregory(); You got to tell it that it is a method after all. :)

Thank you!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1