第 2 章 编写 C# 程序

2.1  Visual Studio 2005开发环境

2.2  控制台应用程序

  试试看:创建一个简单的控制台应用程序

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            // Output text to the screen
            Console.WriteLine("The first app in Beginning C# Programming!");
            Console.ReadKey();
        }
    }
}
View Code

   控制台窗口会在执行完毕后立即关闭,使用 Console.ReadKey(); 告诉代码在结束钱等待按键。

2.3  Windows Forms应用程序

  试试看:创建一个简单的Windows应用程序

 1 using System;
 2 using System.Collections.Generic;
 3 using System.ComponentModel;
 4 using System.Data;
 5 using System.Drawing;
 6 using System.Linq;
 7 using System.Text;
 8 using System.Windows.Forms;
 9 
10 namespace WindowsFormsApplication1
11 {
12     public partial class Form1 : Form
13     {
14         public Form1()
15         {
16             InitializeComponent();
17         }
18 
19         private void button1_Click(object sender, EventArgs e)
20         {
21             MessageBox.Show("The first Windows app in the book!");
22         }
23     }
24 }
View Code
原文地址:https://www.cnblogs.com/liuliu3/p/3756194.html