用户名: 密码: 验证码:           网站地图  高级搜索  RSS订阅  收藏本站
您的位置:主页 > 程序编程 > C# >

体验Visual Studio 2005之局部类型

[ 来源:csdn | 作者:xamcsdn2 | 更新日期:2008-3-26 13:00:22 | 人气: | 评论 0 条 ]
  Visual Studio 2005 [Whidbey] 抢先体验版 [Express Beta 1 ] 出来有一段时间了,并且在微软的官方网站上有免费的下载(下载地址:http://lab.msdn.microsoft.com/vs2005/)。就本人而言是非常喜欢c#这一新生的语言的。也许并不能说它是新生的,它是对以往各种语言的提炼,或许它是站在巨人的肩膀上的,所以才显得如此的优秀。伴随体验版而来的c# 2.0 给我们带来了新的语言特性(generics:泛型; iterators:迭代; partial classes:局部类型; anonymous methods:匿名方法;),使我们能更轻易的编写出简洁明快的代码,当然这些新特性给我们带来的远不止简洁明快的代码。这只有在我们使用的过程中自己体会和别人的交流中了解。

  分别用2003和2005 新建两个WindowsApplication1。

  2003和2005解决方案资源治理器中都会默认建立一个从System.Windows.Forms.Form 类继续的窗体类Form1。

  那我们比较下两个不同的IDE环境为我们自动生成的Form1的代码是怎么样的。

  选中Form1.cs察看代码

  2003:

public class Form1 : System.Windows.Forms.Form

007网络教程网


{
 private System.Windows.Forms.Button button1;
 /// <summary>
 /// 必需的设计器变量。
 /// </summary>
 private System.ComponentModel.Container components = null;

 public Form1()
 {
  //
  // Windows 窗体设计器支持所必需的
  //
  InitializeComponent();
  //
  // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
  //
 }

 /// <summary>
 /// 清理所有正在使用的资源。
 /// </summary>
 protected override void Dispose( bool disposing )
 {
  if( disposing )
  {
   if (components != null)
   {
    components.Dispose();
   }
  }
  base.Dispose( disposing );
 }

 #region Windows 窗体设计器生成的代码
 /// <summary>
 /// 设计器支持所需的方法 - 不要使用代码编辑器修改
 /// 此方法的内容。
 /// </summary>
 private void InitializeComponent()
文章来源于www.hot007.com

 {
  this.button1 = new System.Windows.Forms.Button();
  this.SuspendLayout();
  //
  // button1
  //
  this.button1.Location = new System.Drawing.Point(88, 72);
  this.button1.Name = "button1";
  this.button1.Size = new System.Drawing.Size(72, 32);
  this.button1.TabIndex = 0;
  this.button1.Text = "button1";
  this.button1.Click = new System.EventHandler(this.button1_Click);
  //
  // Form1
  //
  this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
  this.ClientSize = new System.Drawing.Size(292, 273);
  this.Controls.Add(this.button1);
  this.Name = "Form1";
  this.Text = "Form1";
  this.ResumeLayout(false);

 }
 #endregion

 /// <summary>
 /// 应用程序的主入口点。
 /// </summary>
 [STAThread]
 static void Main()
 {
  Application.Run(new Form1());
www.hot007.com

 }

 private void button1_Click(object sender, System.EventArgs e)
 {
 }
}

  2005:

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

 private void button1_Click(object sender, EventArgs e)
 {
 }
}


Tags:体验Visual,Studio,2005之局部类型
您的评论
用户名: 新注册) 密码: 匿名评论 [所有评论]

·用户发表意见仅代表其个人意见,并且承担一切因发表内容引起的纠纷和责任
·本站管理人员有权在不通知用户的情况下删除不符合规定的评论信息或留做证据
·请客观的评价您所看到的资讯,提倡就事论事,杜绝漫骂和人身攻击等不文明行为