About

I am a software developer in Seattle, building a new AI software company.

Ads

August 2009

Sun Mon Tue Wed Thu Fri Sat
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31          

Ads


« Simple Changes To Spiff Up Your App UI | Main | Data Sources »

September 26, 2004

Comments

Dan Golick

I'm not sure I really understand your points. Perhaps you can elaborate.

You say a value type (besides enum) can "override" ToString GetHash etc. to eliminate the cost of boxing. But any virtual call must box first. So perhaps your intention is an overload that hides the virtual function. But in this case the caller must know the final type.

How can a collection store enumerated types as reference types when they are values? Do you mean boxed? So where is the boxing savings?

You may well be right but I will need to see a bit more rigorous proof.

Wesner Moise

If a value to overrides ToString(), etcs, the resulting override is actually non-virtual, because structs are sealed. There is no need for boxing before calling To.String().

A collection can store the enumerated types as objects, so that they are preboxed. Boxing itself is an expensive operation, ignoring the fact that memory is allocated. But if enumerated types are stored in a collection, they will be repeatedly boxed multiple times; which reference types, they are boxed once.

The comments to this entry are closed.