我正在調試一個WCF項目與雙向通信。我有一個數據回調函數,我在數組中存儲客戶端,一個WinForm,並用它來繪製一個控件。正如你所猜測的,當我讀取數據時,數據從寫入數組(真的是一個列表)中消失。顯示在C#中的引用地址(調試WCF)
對於調試,我想看看我是否寫入和閱讀相同的對象,以便回調函數沒有做出某種副本並將其扔掉。例如,我想查看這個指針的地址。我如何在VS2010 Exp中做到這一點?
編輯
一些代碼:
字段聲明:
// the cards that the player have
private List<Card> cards = new List<Card>();
回調處理:
private void btnDraw_Click(object sender, EventArgs e)
{
Tuple<Card, string> update = PressedDraw(this);
cards.Add(update.Item1);
PaintCards();
}
漆事件:
private void cardPanel_Paint(object sender, PaintEventArgs e)
{
int counter = 0;
Point fromCorner = new Point(20,12);
int distance = 50;
foreach (Card card in cards)
{
Point pos = fromCorner;
pos.Offset(counter++ * distance, 0);
Bitmap cardBitmap =
cardFaces[Convert.ToInt32(card.suit),
Convert.ToInt32(card.rank)];
Rectangle square = new Rectangle(pos, cardBitmap.Size);
e.Graphics.DrawImage(cardBitmap, square);
}
當我調試我在回調處理程序首先進入並增加了Card
在cards
PaintCards()
電話Invalidate
和油漆的事件時運行。當在cardPanel_Paint
時,cards.Count
再次爲零。
此致敬禮。
Görgen
謝謝你的回答,它是同一個對象。 – Gorgen 2010-11-03 08:06:38
非常感謝 - 謝謝! – Andy 2011-05-17 12:55:01