Link to home
Start Free TrialLog in
Avatar of paulwhelan
paulwhelan

asked on

Changing type of some variables

Hi

Im making changes to some code. We had a variable

private string InitialValue

which was used for five different 'data types' (number, date, string, boolean and enumerator)
so it was suggested that instead of it being

private string InitialValue

for each of the five it should be

private object InitialValue



And then within 'number' it should be
private decimal InitialValue

and within 'date' it should be
private datetime InitialValue

and within 'string' it should be
private boolean InitialValue

and within 'boolean' it should be
private datetime InitialValue


with the aim being that only decimals will be entered as the Initial Value for a number, only booleans will be entered as the Initial Value for booleans.

My question is what should it be for enumerator?

Any questions let me know

Thanks
Paul
Avatar of paulwhelan
paulwhelan

ASKER

Sorry ...

And then within 'number' it should be
private decimal InitialValue

and within 'date' it should be
private datetime InitialValue

and within 'string' it should be
private string InitialValue

and within 'boolean' it should be
private boolean InitialValue
>> My question is what should it be for enumerator?

it should be the same type as your enum.

for exmaple if you have an enum called X then is should be

private X var
But see the way I changed

private object InitialValue
to
private string InitialValue
(for string)

and

private object InitialValue
to
private datetime InitialValue
(for date)
etc...

How would I represent an enum?

Thanks
Paul

ASKER CERTIFIED SOLUTION
Avatar of newton2k
newton2k

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial