using System; public class MainClass { public static void Main() { Type targetType = typeof(int); object source = "42"; object result = Convert.ChangeType(source, targetType); Console.WriteLine(result); // 42 Console.WriteLine(result.GetType()); // System.Int32 } }