-
c# boxing related question
I have a question regarding boxing in c#.
Currently, I have the need for a map like the following:
Dictionary<string, FieldValue>
Where field value looks something like this (i'm leaving out obvious code):
struct FieldValue
{
public object DataValue {...}
public UnitType Units{...}
}
It has come to my attention that the majority of values I will be storing in this map will be value types, and I will be performing quite a few adds per execution of this program, so I would like to avoid some of the boxing penalty of storing value types in the DataValue parameter of the above object.
Initially I thought, since I know all values will be either a number, a string, or a list of either type, that I would simply create 4 different fields, one for each type and store an enumeration that indicated which field was being used. I don't really like this solution, so another idea I had was to do something like the following (all value types will be stored in doubles):
class DoubleReference
{
public double DoubleValue{...}
}
That way the DoubleReference object could be instantiated beforehand and I think, if I understand correctly how things work, that I would be able to avoid at least an unboxing operation by storing DoubleReference rather than a regular double in the map of generic object types.
My question is, does doing this make any sense? Will it gain me anything at all, or am I wasting my time here? Thanks in advance for any help.
Mike
Similar Threads
-
By radhika743 in forum Java
Replies: 0
Last Post: 06-17-2007, 11:54 PM
-
Replies: 1
Last Post: 02-13-2003, 04:48 PM
-
By Chris Hylton in forum VB Classic
Replies: 0
Last Post: 06-10-2002, 11:31 AM
-
Replies: 7
Last Post: 02-14-2002, 05:17 PM
-
By Harman Lidder in forum Java
Replies: 2
Last Post: 05-11-2001, 05:34 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks