嘿,我是新来的C#和我正在跟随一个教程,但我在我的代码中得到一个错误...它说:“标识符预期”在这里(get; set;),也给出了错误“令牌无效';'在类,结构或接口成员声明“中。标识符预计c#
任何帮助都将不胜感激。
谢谢!
public class Invoice
{
public int ID (get; set;)
public string Description (get; set;)
public decimal Amount (get; set;)
}
[TestClass]
public class ReferenceTypesAndValueTypes
{
[TestMethod]
public void IdentityTest()
{
Invoice firstInvoice = new Invoice();
firstInvoice.ID = 1;
firstInvoice.Description = "Test";
firstInvoice.Amount = 0.0M;
Invoice secondInvoice = new Invoice();
secondInvoice.ID = 1;
secondInvoice.Description = "Test";
secondInvoice.Amount = 0.0M;
Assert.IsFalse(object.ReferenceEquals(secondInvoice, firstInvoice));
Assert.IsTrue(firstInvoice.ID == 1);
secondInvoice.ID = 2;
Assert.IsTrue(secondInvoice.ID == 2);
Assert.IsTrue(firstInvoice.ID == 1);
secondInvoice = firstInvoice;
Assert.IsTrue(object.ReferenceEquals(secondInvoice,firstInvoice));
secondInvoice.ID = 5;
Assert.IsTrue(firstInvoice.ID == 5);
}
}
大声笑我刚刚评论与“哪里”:P很高兴你编辑 – rlemon
没问题的家伙。 – dtsg