using System.Windows.Forms;
namespace NewAnObjectOfClass
{
class Program
{
static void Main(string[] args)
{
Form MyForm;// 声明一个引用变量MyForm
MyForm = new Form();// 引用变量引用一个实例
MyForm.Text = "MyForm";
MyForm.ShowDialog();
}
}
}
即便是创建的控制台应用程序,如果添加了窗体应用程序的引用,依然可以show出窗体
1.在引用添加System.Windows.Form
2.添加using System.Windows.Forms;
这样就可以show出Form,
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace NewAnObjectOfClass
{
class Program
{
static void Main(string[] args)
{
Form AForm = new Form();
AForm.ShowDialog();
}
}
}
程序依下面更改也是可行的
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace NewAnObjectOfClass
{
class Program
{
static void Main(string[] args)
{
(new Form()).ShowDialog();
}
}
}