InvoiceItem
以下で定義された型クラスのオブジェクトの配列があるとします。
private class InvoiceItem
{
public DateTime InvoiceDate { get; set; }
public int InvoiceID { get; set; }
public byte ItemType { get; set; }
public short Quantity { get; set; }
public string ProductName { get; set; }
public decimal Price { get; set; }
public decimal Amount{ get; set; }
public InvoiceItem(DateTime InvoiceDate,int InvoiceID, short Quantity, string ProductName, decimal Price,decimal Amount, byte ItemType)
{
this.InvoiceDate = InvoiceDate;
this.InvoiceID = InvoiceID;
this.Quantity = Quantity;
this.ProductName = ProductName;
this.Price = Price;
this.Amount = Amount;
this.ItemType = ItemType;
}
}
という名前の配列にアイテムをキャッシュしようとしますinvoiceItemsCache
private InvoiceItem[] invoiceItemsCache;
キャッシュを更新するたびに、アレイを再初期化します。
invoiceItemsCache = new InvoiceItem[count];
以前のキャッシュで使用されたメモリを解放するために何かをする必要がありますか、それとも自動的に行われますか? 私が遭遇した疑いや混乱を取り除くために、配列がC#で保存および解放される方法について誰かが追加情報を提供してくれれば幸いです。