C#学习笔记—控制台与消息框输出

控制台输出:

 1 using System;
 2 
 3 namespace ConsoleOutApp
 4 {
 5     class Program
 6     {
 7         static void Main(string[] args)
 8         {
 9             Console.Write("Welcome to C#\n");
10         }
11     }
12 }

消息框输出:

       直接声明命名空间using System.Windows.Forms;会提示查找不到该命名空间,要做的是:

项目——忝加引用-----在.net组件里面找到-------System.Windows.Forms.dll---对击选中它,这样就能够声明该命名空间了。

         代码如下:

 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Text;
 5 using System.Windows.Forms;
 6 
 7 namespace ForOutApp
 8 {
 9     class Program
10     {
11         static void Main(string[] args)
12         {
13             MessageBox.Show("Welcome to C#");
14         }
15     }
16 }

         程序在执行时还是会生成控制台的黑框框,然后弹出一个消息框。

原文地址:https://www.cnblogs.com/johnpher/p/2733763.html