我的代碼,我得到3個消息都說object initialization can be simplified
,在我的知識不斷增長的渴求(和我的OCD),我想「修理」我的代碼,這些消息不出現。我知道我可以只設置它,以便這些信息不出現,但我仍然會在我的頭上,他們是有其犯規背景坐的權利和我在一起。如果任何人都可以指出如何「簡化初始化」,這將是巨大的,所以我可以提高我的技能。如果需要更多的代碼,讓我知道,我可以將它添加對象初始化可以簡化
1:
TreeNode node = new TreeNode(drive.Substring(0, 1), driveImage, driveImage);//issue on this line
node.Tag = drive;
第二:
DirectoryInfo di = new DirectoryInfo(dir);
TreeNode node = new TreeNode(di.Name, 0, 1); //this line
我的TreeNodes,懷疑它,因爲我有給他們相同的名字,但我試圖改變名字,但沒有什麼區別。
3:
OleDbCommand select = new OleDbCommand();//this line
select.Connection = cnDTC;
select.CommandText = string.Format("SELECT MAX(VERSION_NO) AS MAX_VERSION FROM ({0})", strSQL2);
好奇心和願意提高技能+1;) –