Potentially embarrassing question, but there is obviously something I'm missing that I want/need to know.
I expect the following code to create a new table row with new cells to be rendered later. And that's what it does ... as you would expect.
using (TableRow tr = new TableRow())
{
using (TableCell td = new TableCell())
{
td.Text = "Column A";
tr.Cells.Add(td);
}
using (TableCell td = new TableCell())
{
td.Text = "Column B";
tr.Cells.Add(td);
}
tbl.Rows.Add(tr);
}
But .... but aren't the TDs created in the using statements invalidated once they go out of the 'using' scope? Wouldn't the TD objects referenced by the row now be invalid and shouldn't the row fail when it attempts to use them? The same could be said for the TR when it's rendered by the 'tbl' object.
Do I not understand dispose?
Do I not understand using?
Is TableRow.Cells.Add() actually doing a deep copy not just a ref ptr copy?
Can the TableCell actually be used after it's disposed?
What gives?