Coming from an Excel VBA background I would frequently write code such as:
Range("myRange").Offset(0, 1).Resize(1, ccData).EntireColumn.Delete
I'm now moving to VSTO, and have been reading about RCW counters, etc., and the need to explicitly release COM objects. The basic advice seems to be: don't chain together references to Excel objects (as I have above) - hence "one dot good, two dots bad".
My question is, am I correct that the above code is not the way to go in VSTO? If so, does that mean that I would need to explicitly declare the 3 ranges implied in the above chain (Offset, Resize & EntireColumn)?
Or even how about something like:
rng.Columns.Count
where rng is a declared Range? Should I be assigning a name to rng.Columns in order to obtain the number of columns in the range??
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…