I’m creating a program where I save information in a XML, in that XML I put the value and its type (DataType is an XML).
Is there a way to get that value in a object variable with its datatype? I’m having problems where the value is a string or decimal, integers, etc.
EXAMPLE:
<Answer ProblemID="0" ObjectiveID="1" IsCorrect="False">
<Result DataType="System.Nullable`1[System.Decimal]" Value="45" />
</Answer>
<Answer ProblemID="0" ObjectiveID="1" IsCorrect="False">
<Result DataType="System.Nullable`1[System.Decimal]" Value="Null" />
</Answer>
<Answer ProblemID="0" ObjectiveID="5" IsCorrect="False">
<Result DataType="System.Nullable`1[Factory.Factories.Comparison2.Comparators]" Value="Null" />
</Answer>
sounds like what you want is xml serialization, something like this:
edit
you can control how the object is serialized by using attributes on the items you want to serialize (or not):
more information here on msdn