假設我有如下定義類型類InvoiceItem
的對象的數組:我是否需要釋放C#中數組使用的內存?
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#中的存儲和發佈方式的附加信息,以便消除我遇到的任何疑問和困惑,我將不勝感激。
也許他應該「處理一些引用」,但肯定不會「處理()」它們。文字的挑剔。 –