如何将控制台应用程序转换为winforms?

时间:2014-08-13 13:00:46

标签: c# winforms

我想在这里做一些更改,我想将此应用程序转换为winforms。我想将这些输出存储到文本文件中,我该怎么做?请帮忙

using System;
using System.Threading;
public static class Program
{
public static void Main()
{
     // Create a Timer object that knows to call our TimerCallback
  // method once every 2000 milliseconds.
  Timer t = new Timer(TimerCallback, null, 0, 1000);
  // Wait for the user to hit <Enter>
   Console.ReadLine();
}

private static void TimerCallback(Object o) 
{
   // Display the date/time when this method got called.
  Console.WriteLine(DateTime.Now);
  // Force a garbage collection to occur for this demo.
  GC.Collect();
 }
}

此应用程序的输出。

enter image description here 来源Stackoverflow

2 个答案:

答案 0 :(得分:0)

转到应用>,将应用类型更改为Winform,然后在Sub Main

指向启动对象

答案 1 :(得分:0)

右键单击解决方案并选择“添加参考” 选择System.Windows.Forms并单击OK

相关问题