Ok The following code:
Code:
//Language: C#
//Author: RR
//Date: 11-14-04
//Description: A calculator to add two usre inputs.
//The system .NET files to use
using System;
using System.Drawing;
using System.Windows.Forms;
//The class used for the application:
Class App
{
public static void Main()
{
Application.Run(new Calc());
}
}
//the class for the Calc() function
class Calc:Form
{
TextBox inputA;
TextBox inputB;
ListBox Answer;
Button Add;
public Calc()
{
inputA = new TextBox();
inputA.Location=new Point(16,16);
inputB=new TextBox();
inputB.Location=new Point(28,16);
Button Add=new Button();
Add.Location=new Point(16,48);
Add.Size=new Size(70,20);
Add.Text="Add!";
Add.Click += new EventHandler(OnClick);
AcceptButton=Add;
Answer=new ListBox();
Answer.Location=new Point(16,88);
Answer.Size=new Size(190,130);
Answer.Anochor=AnchorStyles.Top|AnchorStlyes.Bottom|AnchorStyles.Left|AnchorStyles.Right;
ClientSize=new Size(255,255);
Controls.AddRange(new Control[]
{
inputA,inputB,Add,Answer
});
Text="Calculator";
}
void OnClick(Object sender, EventArgs e)
{
try{
Int32 A = Convert.ToInt32(inputA.Text);
Int32 B = Convert.ToInt32(inputB.Text);
if(A>100||B>100)
throw new Exception();
Answer.Items.Clear();
Decimal ABC=A+B;
Answer.Items.Add(ABC);
}
Answer.SelectedIndex = Answer.Items.Count-1;
}
catch
{
MessageBox.Show("Both inputs must be less than 101, not including 101");
}
}
When I try to compile it using csc.exe I get the following error:
Calc.cs(13,1): error CS0116: A namespace does not directly contain members such
as fields or methods
Calc.cs(15,16): error CS1518: Expected class, delegate, enum, interface, or
struct
Calc.cs(19,1): error CS1022: Type or namespace definition, or end-of-file
expected
I've tried checning the Class APP to Class App, and some other things, but I'm not quite sure WHAT the compiler is saying is wrong with it. If anybody could help I would appreciate it very much.