I have a problem with a delegate in the class on a project I'm working on. A class is a GUI component that accepts both a label and a value. The idea here is that the user can specify a label, and then refer to a value from anywhere (more precisely, this is the ToString Method value), so every time this value is updated, the GUI component also. Here's how it works:
public delegate string GUIValue();
public class GUIComponent
{
GUIValue value = null;
string label = "";
string text = "";
public GUIComponent(string Text, GUIValue Value)
{
this.text = Text;
this.value += Value;
}
public void Update()
{
this.text = this.label + this.value();
}
}
And then I call it that
GUIComponent component = new GUIComponent("Label: ",
new GUIValue(this.attribute.ToString));
The code compiles correctly, and the component displays and displays the initial value for this attribute, however, it does not update when the attribute value changes.
, , , . , return ToString, , - ?