【发布时间】:2018-09-15 16:14:34
【问题描述】:
我有一个课程Insurance 和InsuranceTest,这些课程是一个更大的项目的一部分,入口点static void main(string[] args)。它拒绝执行这个入口点并且不打印出我的结果。
保险类别
namespace IT
{
class Insurance
{
int cust;
string agent;
string state;
public Insurance(int cust, string agent, string state)
{
this.cust = cust;
this.agent = agent;
this.state = state;
}
public Insurance(int cust, string agent)
: this(cust, agent, "")
{
}
public int Cust
{
get { return cust; }
set { cust = value; }
}
public string Agent
{
get { return agent; }
set { agent = value; }
}
public string State
{
get { return state; }
set { state = value; }
}
public static void main(string[] args)
{
Employee e1 = new Employee("Sugar", "Insurance Ave", 6534);
e1.Name = "Sugar";
e1.Address = "Insurance Ave";
e1.Id = 6534;
Console.WriteLine(e1.Name);
Console.WriteLine(e1.Address);
Console.WriteLine(e1.Id);
}
}
}
保险测试类
namespace IT
{
class InsuranceTest
{
static void main(string[] args)
{
Insurance i1 = new Insurance(7, "Agent Store", "PA");
i1.Customers = 7;
i1.Agent = "Agent Store";
i1.State = "PA";
Console.WriteLine("Total Customers" + i1.Cust);
Console.WriteLine(i1.Agent);
Console.WriteLine(i1.State);
}
}
}
注意:InsuranceTest 不是从入口点执行的。这些是许多类的类,当我在 Visual Studio 中转到项目的属性并尝试选择和启动对象时。 InsuranceTest 甚至没有出现。
【问题讨论】:
-
方法区分大小写,你的主要方法是小写。
标签: c# console.writeline