且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在C#更改Windows自动生成的代码窗体应用程序项目

更新时间:2023-09-24 23:12:40

为什么要更改自动生成的文件?
在形式的情况下,你不应该改变了.Designer.cs或.resx文件,因为它们会生成每次你改变所以无论改变你将被覆盖的代码再生下一次的形式。

。如果你想改变在Designer.cs东西,你可以做原来的CS文件的变化,因为该类被标记为局部的,这意味着从文件Form1.cs和Form1.designer.cs代码如果你想添加你的资源添加一个资源文件,并保留生成的.resx文件的完整结合起来,以产生最终代码。结果

。对于AssemblyInfo.cs中,您可以更改组件的一般信息。

Why do you want to change the auto-generated files?
In case of forms you should not change .Designer.cs or the .resx files because they will be generated everytime you change the form so whatever changes you do will be overwritten next time the code is regenerated.
If you want to change something in Designer.cs, you can do that change in the original cs file because the class is marked as partial which means that the code from the files Form1.cs and Form1.Designer.cs is combined to generate the final code.
If you want to add your resources add a resource file and leave the generated .resx file intact. For AssemblyInfo.cs you can change the general information of the assembly.

长话短说见好就收生成的文件完好无损。

Long story short just leave the generated files intact.