【发布时间】:2011-07-19 11:35:42
【问题描述】:
指的是类变量的构造函数,可以在这个类期间分配工作。我如何在这个类中进行,我无法在构造函数中将它们分配给它们,而是在不同的方法中?
创建类:
CreatePackWindow createPackWindow = new CreatePackWindow(ref title, ref description);
if (createPackWindow.ShowDialog() == true)
{
Console.WiteLine(title, description);
}
类 CreatePackWindow:
public partial class CreatePackWindow : Window
{
public CreatePackWindow(ref string title, ref string description)
{
InitializeComponent();
}
private void btnCreate_Click(object sender, RoutedEventArgs e)
{
???title = tbPackName.Text; **// How to assign here?**
???description = tbDescription.Text; **// How to assign here?**
this.DialogResult = true;
Close();
}
//..........
}
我知道您需要创建指向 title 和 description 的指针以及使用它们的方法,但不知道该怎么做:(
请帮忙。 谢谢。
【问题讨论】: