【发布时间】:2014-08-24 16:41:09
【问题描述】:
我是 c# 新手,这个项目仅用于学习目的。我试图制作一个程序,用户在命令行中输入一些信息,然后结果显示在表单窗口中。我怎样才能使它工作?
这是我失败的尝试:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Øving1
{
class Program
{
static int Length;
static int Width;
[STAThread]
static void Main(string[] args)
{
GUI test = new GUI();
Console.WriteLine("Dette Programet regner ut areal og omkrets av et rektangel, angi en lengde og brede(eks. 10 enter 10)");
Length = Convert.ToInt32(Console.ReadLine());
Width = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("AREAL: " + Area(Length, Width) + " OMKRETS: " + Circumference(Length, Width));
test.richTextBox1.Clear();
test.richTextBox1.AppendText("AREAL: " + Area(Length, Width) + " OMKRETS: " + Circumference(Length, Width));
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(test);
}
public static int Area(int Length, int Width)
{
return Length * Width;
}
public static int Circumference(int Length, int Width)
{
return (Length * 2) + (Width * 2);
}
【问题讨论】:
-
有什么问题?
-
错误信息的哪一部分你不明白?
标签: c# winforms forms command-line