作者:立而山0605_408 | 来源:互联网 | 2023-06-06 09:07
As i am not very advanced in C# yet, I try to learn how to make my code more efficient. I stored a lot of strings in some of the properties.
由于我在C#方面不是很先进,我尝试学习如何使我的代码更有效率。我在一些属性中存储了很多字符串。
At the start of the application, i load all the seperatie properties into the textboxes. I now ise this code to load them all:
在应用程序的开始,我将所有seperatie属性加载到文本框中。我现在是这个代码加载它们:
private void LoadStoredStrings()
{
txtT1S1.Text = Properties.Settings.Default.strT1L1;
txtT1S2.Text = Properties.Settings.Default.strT1L2;
txtT1S3.Text = Properties.Settings.Default.strT1L3;
txtT1S4.Text = Properties.Settings.Default.strT1L4;
txtT1S5.Text = Properties.Settings.Default.strT1L5;
txtT1S6.Text = Properties.Settings.Default.strT1L6;
txtT1S7.Text = Properties.Settings.Default.strT1L7;
txtT1S8.Text = Properties.Settings.Default.strT1L8;
txtT1S9.Text = Properties.Settings.Default.strT1L9;
txtT1S10.Text = Properties.Settings.Default.strT1L10;
}
Obvious i can see the logic that each stored propertie ending with T1L1
also fits to the txt that ends with T1S1
. I just know this should be done in a more elegant and solid way than what i did now. Could anyone push me in the right direction?
显而易见,我可以看到以T1L1结尾的每个存储属性也适合以T1S1结尾的txt的逻辑。我只知道这应该以比我现在更优雅和坚实的方式完成。有人能把我推向正确的方向吗?
2 个解决方案