C#实现网络点对点具体步骤

开发 后端
这里介绍C#实现网络点对点具体步骤,在(解决方案资源管理器)窗口中,双击Form1.cs文件,进入Form1.cs文件的编辑界面。以下面代码替代系统产生的InitializeComponent过程。

C#有很多值得学习的地方,这里我们主要介绍C#实现网络点对点具体步骤,包括介绍Visual Studio .Net集成开发环境等方面。

C#实现网络点对点具体步骤:

在了解、掌握了关键问题及其解决方法,再实现用Visual C#实现网络点对点通讯程序相对就容易许多,下面是具体的实现步骤:

1.启动Visual Studio .Net,并新建一个Visual C#项目,名称为(Visual C#实现网络点对点通讯程序)。

2.在Visual Studio .Net集成开发环境中的(解决方案资源管理器)窗口中,双击Form1.cs文件,进入Form1.cs文件的编辑界面。

3.在Form1.cs文件的开头,用下列导入命名空间代码替代系统缺省的导入命名空间代码。

  1. using System ;  
  2. using System.Drawing ;  
  3. using System.Collections ;  
  4. using System.ComponentModel ;  
  5. using System.Windows.Forms ;  
  6. using System.Data ;  
  7. using System.Net.Sockets ;  
  8. using System.Net ;  
  9. using System.IO ;  
  10. using System.Text ;  
  11. using System.Threading ; 

4.再把Visual Studio.Net的当前窗口切换到(Form1.cs(设计))窗口,并从(工具箱)中的(Windows窗体组件)选项卡中往窗体中拖入下列组件:

四个Button组件;二个ListBox组件;四个TextBox组件;一个StatusBar组件;五个Label组件。并在四个Button组件拖入窗体后,分别在窗体设计界面中双击它们,则系统会在Form1.cs文件中分别产生这四个组件的Click事件对应的处理代码。

5.在(解决方案资源管理器)窗口中,双击Form1.cs文件,进入Form1.cs文件的编辑界面。以下面代码替代系统产生的InitializeComponent过程。下面代码是对上面添加的组件进行初始化:

  1. private void InitializeComponent ( )  
  2. {  
  3. this.listBox1 = new System.Windows.Forms.ListBox ( ) ;  
  4. this.textBox1 = new System.Windows.Forms.TextBox ( ) ;  
  5. this.label3 = new System.Windows.Forms.Label ( ) ;  
  6. this.label2 = new System.Windows.Forms.Label ( ) ;  
  7. this.textBox3 = new System.Windows.Forms.TextBox ( ) ;  
  8. this.button1 = new System.Windows.Forms.Button ( ) ;  
  9. this.textBox2 = new System.Windows.Forms.TextBox ( ) ;  
  10. this.label1 = new System.Windows.Forms.Label ( ) ;  
  11. this.label4 = new System.Windows.Forms.Label ( ) ;  
  12. this.label5 = new System.Windows.Forms.Label ( ) ;  
  13. this.button2 = new System.Windows.Forms.Button ( ) ;  
  14. this.button3 = new System.Windows.Forms.Button ( ) ;  
  15. this.button4 = new System.Windows.Forms.Button ( ) ;  
  16. this.textBox4 = new System.Windows.Forms.TextBox ( ) ;  
  17. this.statusBar1 = new System.Windows.Forms.StatusBar ( ) ;  
  18. this.statusBarPanel1 = new System.Windows.Forms.StatusBarPanel( );  
  19. this.statusBarPanel2 = new System.Windows.Forms.StatusBarPanel( );  
  20. this.label6 = new System.Windows.Forms.Label ( ) ;  
  21. this.listBox2 = new System.Windows.Forms.ListBox ( ) ;  
  22. ( ( System.ComponentModel.ISupportInitialize )  
  23. ( this.statusBarPanel1 ) ).BeginInit ( ) ;  
  24. ( ( System.ComponentModel.ISupportInitialize )  
  25. ( this.statusBarPanel2 ) ).BeginInit ( ) ;  
  26. this.SuspendLayout ( ) ;  
  27. this.listBox1.ItemHeight = 12 ;  
  28. this.listBox1.Location = new System.Drawing.Point ( 122 , 110 ) ;  
  29. this.listBox1.Name = "listBox1" ;  
  30. this.listBox1.Size = new System.Drawing.Size ( 212 , 88 ) ;  
  31. this.listBox1.TabIndex = 4 ;  
  32. this.textBox1.Location = new System.Drawing.Point ( 122 , 18 ) ;  
  33. this.textBox1.Name = "textBox1" ;  
  34. this.textBox1.Size = new System.Drawing.Size ( 210 , 21 ) ;  
  35. this.textBox1.TabIndex = 1 ;  
  36. this.textBox1.Text = "" ;  
  37. this.label3.Location = new System.Drawing.Point ( 220 , 52 ) ;  
  38. this.label3.Na  

【编辑推荐】

  1. C#创建表单简单介绍
  2. C#修改DataReader默认行为
  3. C#设置CooperativeLevel概述
  4. C#表单增加控件简单描述
  5. C# EmployeePlug类概述
责任编辑:佚名 来源: 博客园
相关推荐

2010-06-21 17:05:00

Linux Arch

2010-01-12 11:55:10

VB.NET网络监控

2010-06-22 14:55:21

autoconf安装

2009-12-07 10:46:08

WCF框架

2010-07-28 16:33:43

Fedora 10ADSL网络连接

2010-05-10 18:15:16

Oracle跨服务器

2010-04-02 11:41:51

单机无线上网

2010-05-10 17:34:17

Oracle 客户端配

2010-10-08 11:29:24

JavaScript对象

2010-08-02 17:08:34

Flex Eclips

2010-09-25 16:30:25

DHCP选项设置

2010-07-02 09:48:58

2003 SNMP启用

2010-02-22 10:52:34

PDA访问WCF

2009-01-30 21:56:00

2010-04-02 11:53:11

双机共享无线上网

2009-09-03 13:54:12

C#实现局域网点对点

2011-04-07 14:53:18

路由器局域网宽带路由器

2010-04-08 17:51:05

Oracle表列

2010-09-03 11:53:09

华为DHCP配置

2010-06-08 18:59:03

OpenSUSE li
点赞
收藏

51CTO技术栈公众号