哪個聲明/實例化更好,爲什麼?在構造函數或類的頂部創建一個對象
public class MainWindow
{
private Test _test;
public MainWindow()
{
_test = new Test();
}
}
OR
public class MainWindow
{
private Test _test = new Test();
public MainWindow()
{
}
}
重複的一個.... 請參閱http://stackoverflow.com/questions/298183/c-member-variable-initialization-best-practice – Tony 2010-11-18 21:31:49