Changing autogenerated code in a C# Windows Forms Application project

前端 未结 3 1227
时光说笑
时光说笑 2020-12-11 11:37

When you open a new C# Windows Forms Application project in Visual Studio 2008, you get a lot of autogenerated code (AssemblyInfo.cs, Resources.Designer.cs, Settings.Designe

3条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-11 12:16

    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.

提交回复
热议问题