相关疑难解决方法(0)

无法使用System.Windows.Forms

我试过制作(我的第一个)C#程序:

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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("hello");
            Console.ReadLine();
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

这很顺利,但如果我尝试使用System.Windows.Forms:

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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("hello");
            System.MessageBox("hello");
            Console.ReadLine();
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

这是我得到的错误:

Error   1   The type or namespace name 'Windows' does not exist in the namespace     'System' (are you missing an assembly reference?)  C:\Users\Ramy\Documents\Visual Studio 2010\Projects\ConsoleApplication1\ConsoleApplication1\Program.cs  5   14 …
Run Code Online (Sandbox Code Playgroud)

c# visual-studio winforms

68
推荐指数
6
解决办法
18万
查看次数

标签 统计

c# ×1

visual-studio ×1

winforms ×1