c# 牛人帮我看看这几行代码为啥会报错

assubby 2016-09-04 01:31:16
using System;
using System.Collections.Generic;
using System.Linq;

namespace stock.Domain
{
public class Vault
{
public decimal Money => money;
public decimal InitialMoney => initialMoney;
public Transaction CurrentTransaction => currentTransaction;

private decimal money { get; set; }
private decimal initialMoney { get; set; }
private Transaction currentTransaction { get; set; }

readonly Func<decimal, decimal> computeBankFees;

private List<Transaction> transactions
{
get;
set;
}

public Vault(decimal initialAmount, Func<decimal, decimal> computeBankFees)
{
if (computeBankFees == null)
throw new ArgumentNullException("computeBankFees");

this.initialMoney = initialAmount;
this.computeBankFees = computeBankFees;
this.money = initialAmount;

this.transactions = new List<Transaction>();
}

public decimal GetMargin()
{
return this.Money - this.InitialMoney;
}

public void DisplaySummary()
{
Console.WriteLine("Summary - Current Position:{0:C2} - Margin:{1:C2}", this.Money, GetMargin());
Console.WriteLine();
}

public decimal GetTotalBankFees()
{
return transactions.Sum(t => t.BankFee);
}

public int GetTransactionCount()
{
return transactions.Count();
}

public bool Add(Transaction transaction)
{
transaction.BankFee = computeBankFees(transaction.GetAmount());

if (transaction is BuyTransaction)
{
//Have enough Money ?
if (this.currentTransaction == null && (transaction.GetAmount() + transaction.BankFee) <= money)
{
this.transactions.Add(transaction);

money -= transaction.GetAmount() + transaction.BankFee;
currentTransaction = transaction;

return true;
}
else
{
return false;
}
}
else if (transaction is SellTransaction)
{
//Have enough titles ?
if (this.currentTransaction != null && transaction.Count <= this.currentTransaction.Count)
{
this.transactions.Add(transaction);

money += transaction.GetAmount() - transaction.BankFee;
transaction.LinkedTransaction = currentTransaction;
currentTransaction = null;

return true;
}
else
{
return false;
}
}
else
{
return false;
}
}
}
}


错误 12 应输入 ; C:\Users\luo\Downloads\StockExplorer-master\stock.Domain\Vault.cs 9 30 stock.Domain
错误 13 类、结构或接口成员声明中的标记“;”无效 C:\Users\luo\Downloads\StockExplorer-master\stock.Domain\Vault.cs 9 38 stock.Domain

...全文
188 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
threenewbee 2016-09-04
  • 打赏
  • 举报
回复
public decimal Money => money; public decimal InitialMoney => initialMoney; public Transaction CurrentTransaction => currentTransaction; 这些写法是 C# 6.0才支持的。如果你用vs2013或更早,需要修改为 public decimal Money { get { return money; } } 其它类似
Poopaye 2016-09-04
  • 打赏
  • 举报
回复
请安装vs2015

8,497

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 LINQ
社区管理员
  • LINQ
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧