📄 11321.htm
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>入门基础 - 编程入门网</title>
<meta name="keywords" content="入门基础">
<meta name="description" content="入门基础">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="/images/style.css" rel="stylesheet" type="text/css" />
<script src="/js1/head.js"></script>
</head>
<body leftmargin="0" topmargin="0" bgcolor="#efefef" oncopy=nocopy()>
<TABLE width="760" cellPadding="0" cellSpacing="0" bgcolor="#eff7fe" align="center">
<TR>
<TD><a href="/index.htm"><img src="/images/logo1.gif" width="150" height="60" border="0"></a></TD>
<TD width="470" align="right"><script src="/js1/top.js"></script></TD>
<TD width="125" align="center"><script src="/js1/topsy.js"></script></TD>
</TR>
</TABLE>
<table width="760" border="0" cellpadding="1" cellspacing="0" class="bklan" align="center">
<tr>
<td align="center" bgcolor="#eff7fe" height="24"> | <a href='/Programming/index.htm'>编程语言</a> | <a href='/webkf/index.htm'>web开发</a> | <a href='/data/index.htm'>数据库</a> | <a href='/Network/index.htm'>网络技术</a> | <a href='/OS/index.htm'>操作系统</a> | <a href='/Servers/index.htm'>服务器</a> | <a href='/web/index.htm'>网页设计</a> | <a href='/Design/index.htm'>图形设计</a> | <a href='/Office/index.htm'>办公软件</a> | <a href='/soft/index.htm'>常用软件</a> | <a href='/shadu/index.htm'>杀毒频道</a> | <a href='/PC/index.htm'>学电脑</a> |</td>
</tr>
</table>
<table cellspacing="0" cellpadding="0" width="760" align="center" bgcolor="#ffffff" border="0">
<tr>
<td align="center"><script src="/js1/content1.js"></script></td>
</tr>
</table>
<table width="760" border="0" cellpadding="0" cellspacing="0" align="center">
<tr>
<td height="25" background="/templets/img/31bg3.gif" align="left" class="guidet"> → 当前位置:<a href='http://www.bianceng.cn/'>首页</a>→<a href='/Programming/index.htm'>编程语言</a>→<a href='/Programming/cs/index.htm'>C#</a>→<a href='/Programming/cs/jc/index.htm'>C#教程</a>→正文</td>
</tr>
</table>
<table width="760" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td valign="top" class="guidet" width="595"><table width="100%" border="0" cellpadding="0" cellspacing="0" class="ct">
<tr>
<td align="center" valign="middle" class="til"><h3> 入门基础 </h3>
发布时间:2009-04-14 来源:编程入门网 作者:L小凤<br />
<script src="/js1/468.js"></script>
</td>
</tr>
<tr>
<td style="font-size:14px" align="left" class="til"><table border="0" align="right" cellpadding="0" cellspacing="0">
<tr>
<td align="center"><script src="/js1/300.js"></script></td>
</tr>
</table><p> 2.1 本系列教程中的程序很多是C#的控制台应用程序,Console的中文意思就是控制台,至于后面的C#在数据库和网络方面的应用以后再介绍。下面先看看第一个C#程序。</p>
<p> 在文件—新建—项目—中选择控制台应用程序,选择C#语言。</p>
<p> using System;</p>
<p> using System.Collections.Generic;</p>
<p> using System.Text;</p>
<p> //命名空间,提供特定的类,使您能够与系统进程、事件日志和性能计数器进行交互。</p>
<p> //至于命名空间的作用后续介绍</p>
<p> namespace ConsoleApplication1</p>
<p> {</p>
<p> class Program</p>
<p> {</p>
<p> static void Main(string[] args)//系统主函数,程序运行的起点</p>
<p> {</p>
<p> Console.WriteLine("体会C#编程的乐趣");//在控制台窗口输出“体会C#编程的乐趣”并且换行</p>
<p> Console.ReadKey();//自己编写的,作用是保持控制台窗口直到用户按下任何键结束</p>
<p> }</p>
<p> }</p>
<p> }</p>
<p> 以下是按F5运行后的结果。</p>
<p><img alt="" border="0" src="/upimg/userup/0904/14162104C42.jpg" /></p>
<p> 2.2 windows应用程序</p>
<p> Windows应用程序是C#提供的GUI(用户图形界面)功能,使人机能够通信。在文件—新建—项目—中选择windows应用程序,选择C#语言。下面是一个简单的GUI设计,其中如果没有后台的事件处理程序,点击”点击我”是不会有任何变化的。</p>
<p><img alt="" border="0" src="/upimg/userup/0904/141621545014.jpg" /></p>
<p> GUI设计 运行后点击8次的结果</p>
<p> 系统代码如下</p>
<p> using System;</p>
<p> using System.Collections.Generic;</p>
<p> using System.ComponentModel;</p>
<p> using System.Data;</p>
<p> using System.Drawing;</p>
<p> using System.Text;</p>
<p> using System.Windows.Forms;</p>
<p> namespace window</p>
<p> {</p>
<p> public partial class Form1 : Form</p>
<p> {</p>
<p> int count = 0;//点击次数计数</p>
<p> public Form1()</p>
<p> {</p>
<p> InitializeComponent();//初始化</p>
<p> }</p>
<p> private void button1_Click(object sender, EventArgs e)//点击事件处理</p>
<p> {</p>
<p> count++;//每点击一次计数加</p>
<p> button1.Text = count.ToString();//类型转换</p>
<p> }</p>
<p> }</p>
<p> }</p>
<p> 本小节主要学习了如何创建简单的控制台应用程序和如何启动和运行Windows应用程序,请读者自己尝试下。</p>
<p> 本文为编程入门网.NET专栏作家“L小凤”原创,转载请保留这句话。</p>
<p> 为方便网友脱机使用,本文已经制作成pdf文件,下载地址:</p>
<p> <a target="_blank" href="http://club.bianceng.cn/thread-1030-1-1.html">http://club.bianceng.cn/thread-1030-1-1.html</a></p>
<p> <a href="/Programming/cs/jc/200904/11320.htm">查看全套“C#入门全攻略”</a></p><center><br /><script src="/js1/4682.js"></script></center>
<p>上一篇:<a href='/Programming/cs/jc/200904/11320.htm'>C#入门全攻略</a> 下一篇:<a href='/PC/it/200904/11322.htm'>第三届中国网管员大赛正式开赛</a> </p></td>
</tr>
<tr>
<td align="left" style="font-size:14px;" height="25"><IMG src="/images/t0.gif" width="12" height="12" align=absMiddle><strong>相关文章</strong><br /><table width='100%' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td width='50%'>
·<a href="/Programming/cs/jc/200904/11320.htm">C#入门全攻略</a><br/>
</td>
<td width='50%'>
·<a href="/Programming/cs/jc/200804/9515.htm">孙雯C#进阶教程</a><br/>
</td>
</tr>
<tr>
<td width='50%'>
·<a href="/Programming/cs/jc/200804/9501.htm">善用EditPlus构建精悍的C#编译环境</a><br/>
</td>
<td width='50%'>
·<a href="/Programming/cs/jc/200804/9500.htm">C#数据库事务原理及实践</a><br/>
</td>
</tr>
<tr>
<td width='50%'>
·<a href="/Programming/cs/jc/200804/9499.htm">Windows窗体控件开发示例:扩展TreeView</a><br/>
</td>
<td width='50%'>
·<a href="/Programming/cs/jc/200804/9498.htm">用C#实现木马程序</a><br/>
</td>
</tr>
<tr>
<td width='50%'>
·<a href="/Programming/cs/jc/200804/9497.htm">C#中TreeView组件使用方法初步</a><br/>
</td>
<td width='50%'>
·<a href="/Programming/cs/jc/200804/9496.htm">用C#制作字幕显示屏幕保护</a><br/>
</td>
</tr>
<tr>
<td width='50%'>
·<a href="/Programming/cs/jc/200804/9495.htm">c#中构建异常处理</a><br/>
</td>
<td width='50%'>
·<a href="/Programming/cs/jc/200804/9494.htm">概述C#中的索引器</a><br/>
</td>
</tr>
<tr>
<td width='50%'>
·<a href="/Programming/cs/jc/200804/9493.htm">C#网络编程初探</a><br/>
</td>
<td width='50%'>
·<a href="/Programming/cs/jc/200804/9492.htm">用C#创建COM对象</a><br/>
</td>
</tr>
<tr>
<td width='50%'>
·<a href="/Programming/cs/jc/200804/9491.htm">用C#制作屏幕捕获程序</a><br/>
</td>
<td width='50%'>
·<a href="/Programming/cs/jc/200804/9490.htm">利用C#重启远程计算机</a><br/>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
<td width="165" valign="top" class="guideb"><script src="/js1/1601.js"></script><table width="100%" border="0" cellpadding="0" cellspacing="0" valign="top">
<tr>
<td height="25" align="center" background="/templets/img/31bg3.gif"><strong>阅读排行</strong></td>
</tr>
<tr>
<td>·<a href="/Programming/cs/jc/200711/5352.htm">c#学习教程</a><br/>
·<a href="/Programming/cs/jc/200709/4396.htm">C#的switch语句</a><br/>
·<a href="/Programming/cs/jc/200804/9493.htm">C#网络编程初探</a><br/>
·<a href="/Programming/cs/jc/200711/5340.htm">C#读写文件的方法</a><br/>
·<a href="/Programming/cs/jc/200709/4403.htm">C#的foreach语句</a><br/>
·<a href="/Programming/cs/jc/200709/4322.htm">编写第一个C#应用程序</a><br/>
·<a href="/Programming/cs/jc/200804/9515.htm">孙雯C#进阶教程</a><br/>
·<a href="/Programming/cs/jc/200804/9486.htm">Visual C#的Excel编程</a><br/>
·<a href="/Programming/cs/jc/200709/4395.htm">C#的if语句</a><br/>
·<a href="/Programming/cs/jc/200709/4317.htm">C#语言的特点</a><br/>
·<a href="/Programming/cs/jc/200709/4399.htm">C#的do-while语句</a><br/>
·<a href="/Programming/cs/jc/200711/5350.htm">C#代码优化方法</a><br/>
·<a href="/Programming/cs/jc/200709/4319.htm">什么是clr</a><br/>
·<a href="/Programming/cs/jc/200709/4338.htm">C#变量类型</a><br/>
·<a href="/Programming/cs/jc/200709/4536.htm">C#的虚方法</a><br/>
</td>
</tr>
<tr>
<td><script src="/js1/1602.js"></script></td>
</tr>
<tr>
<td height="25" align="center" background="/templets/img/31bg3.gif"><strong>最新文章</strong></td>
</tr>
<tr>
<td><script src="/plus/js/0.js" language="javascript"></script></td>
</tr>
</table></td>
</tr>
</table>
<table cellspacing="0" cellpadding="0" width="760" align="center" bgcolor="#ffffff" border="0">
<tr>
<td align="center"><script src="/js1/content2.js"></script></td>
</tr>
</table>
<table width="760" border="0" cellspacing="0" cellpadding="0" align="center">
<tr height="26">
<td bgcolor="#e1f0fd" width="48"></td>
<td bgcolor="#6ab3f4" width="35"></td>
<td bgcolor="#0a518f" colspan="2" width="4"></td>
<td bgcolor="#c0c0c0" width="530" align="center"><a title="将本站设为你的首页" onclick="this.style.behavior='url(#default#homepage)';this.sethomepage('http://www.bianceng.cn');return false;" href="http://www.bianceng.cn/">设为首页</a> | <a class="navmenu"
title="将本站加入到你的收藏夹"
href="javascript:window.external.AddFavorite(location.href,document.title)">加入收藏</a> | <a href="/about/about.htm">关于本站</a> | <a href="/plus/flink.php">友情链接</a> | <a href="/about/banquan.htm">版权声明</a> | <a href="/plus/sitemap.html">网站地图</a> | <a href="/plus/rssmap.html">RSS订阅</a></td>
<td bgcolor="#0a518f" colspan="2" width="4"></td>
<td bgcolor="#6ab3f4" width="32"></td>
<td bgcolor="#e1f0fd" width="47"></td>
</tr>
<tr height="26">
<td colspan="9" bgcolor="#FFFFFF" align="center">编程入门网 版权所有,bianceng.cn,All Rights Reserved. <script src="/js/tongji.js"></script> 阅读次数:<script src="/plus/count.php?aid=11321&mid=0" language="javascript"></script></td>
</tr>
</table>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -