I would create a new class to encapsulate the decimal-or-string feature, for
example MyClass. When you create its instance you call pass any either a
string or a decimal to its constructor. It would then have four properties
that you can use to handle both cases:
1) object Value: the raw, indeterminate value of the cell
2) bool IsString: determines if the cell value is a string, perhaps by
'return this.Value is string';
3) string StringValue { get { return this.Value as string; } }
3) decimal? DecimalValue { get { return this.Value as decimal?; } }
Then your dictionary would be of type
public Dictionary<string, MyClassValues;
Let me know if this design is acceptable in your situation.
--
Stanimir Stoyanov
http://stoyanoff.info
"Luigi" <ci****************@inwind.itwrote in message
news:A0**********************************@microsof t.com...
Hi all,
I have an object (named Voice) that has a dictionary like this:
public Dictionary<string, decimal?Values;
Voice is like an Excel cell, the "string" is the name of the column and
decimal nullable is its value.
Now we have discovered that tha value is not only numeric, but can be also
a
description (a string).
How can I refactor my code to incapsulate this new feature?
Thanks in advance.
--
Luigi
http://blogs.dotnethell.it/ciupaz/