我正在制作一个Info
应该在屏幕上显示一些文本的图形控件类。文本是某个对象的字符串。我希望能够从Info
类的实例中获取该对象的最新值。
class Info
{
public string Text;
}
void Program()
{
ClassA obj = new ClassA();
obj.name = "Instance of ClassA";
Info wind1 = new Info();
wind1.Text = obj.name; // this just copies current value, but should be a reference or something
/* obj.name value changes several times before it's time to display it again */
// Info window drawing method
foreach (var item in Windows) // Windows is List<Info>
Draw(item.Text); // this doesn't get the latest value
}
我应该如何更改代码以便从绘图部分中获取最新的字符串值?