banktransaction.cs
来自「csharp-solution,C#高效编程源码」· CS 代码 · 共 44 行
CS
44 行
using System;
using System.IO;
/// <summary>
/// A BankTransaction is created every time a deposit or withdrawal occurs on a BankAccount
/// A BankTransaction records the amount of money involved, together with the current date and time.
/// </summary>
public class BankTransaction
{
private readonly decimal amount;
private readonly DateTime when;
public BankTransaction(decimal tranAmount)
{
amount = tranAmount;
when = DateTime.Now;
}
public decimal Amount()
{
return amount;
}
public DateTime When()
{
return when;
}
public void Dispose()
{
Finalize();
}
~BankTransaction()
{
StreamWriter swFile = File.AppendText("Transactions.Dat");
swFile.WriteLine("Date/Time: {0}\tAmount: {1}", when, amount);
swFile.Close();
GC.SuppressFinalize(this);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?