C#2.0初体验之WinForm篇
今天试探性的打开了66.178.223.73的VS2005,添加了个Form和几个控件,里面的代码让我有点郁闷
Form1.cs里面基本没有什么代码
#region Using directives

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Windows.Forms;

#endregion

namespace WindowsApplication3
{
partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
{

}
}
}
#region Using directives

using System;
using System.Collections.Generic;
using System.Windows.Forms;

#endregion
#region Using directives

using System;
using System.Collections.Generic;
using System.Windows.Forms;

#endregion

namespace WindowsApplication3
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.EnableRTLMirroring();
Application.Run(new Form1());
}
}
}
4.文件目录改变,将项目的属性文件放入Properties文件夹中。
其它细节发现有待以后发觉。文笔不佳请勿见笑!
Form1.cs里面基本没有什么代码


























就只有构造函数,控件的事件响应函数,而且遍寻不见构造函数调用的InitializeComponent(),在这种情况下边一竟然能够通过,而且没有控件的创建代码控件也能正常显示。于是在解决方案浏览器中寻找相关代码,结果点开Form1.cs前的加号发现了Form1.Designer.cs文件,原来全藏在这里,而且这个文件的类名也是
Form1,不过前面加了修饰符Partial。
查阅相关资料才知道,Partial可将一个类的代码分配到不同的文件中,Class声明前加修饰符partial,partial 可用于 class, interface, struct 等,在 vs.net 2005 里面的 winform 和 web service wrapper 等都会使用该技术封装设计器生成的代码。
通过进一步了解发现以下几点不同:
1. partial类的使用,分离VS自动生成的代码。
2. 引用类 代码用#Regien 包起来了







3. 程序入口改以前在Form1里面到单独的类中。
























4.文件目录改变,将项目的属性文件放入Properties文件夹中。
其它细节发现有待以后发觉。文笔不佳请勿见笑!
分类:
ASP.NET
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
· 周边上新:园子的第一款马克杯温暖上架