Convert variable data type based on other variable data type

How to convert certain variable’s data type based on other variable’s data type.
EX:

  1. test1 - System.String
  2. test2 - System.Double

Scenario is we don’t know the data type of test2 in the first place. Goal - convert test1’s’ data type the same as test2’s data type.

@Jerome_Cabutotan1

If you want to know what type of variable it is then try below one.

yourVariable.GetType()

https://docs.microsoft.com/en-us/dotnet/api/system.object.gettype?view=netframework-4.8

Thanks. But how can i use the result of this to convert certain variable?

1 Like

@Jerome_Cabutotan1

Please check below thread.

https://stackoverflow.com/questions/1547594/cast-a-variable-to-a-type-represented-by-another-type-variable