using uCalcSoftware; var uc = new uCalc(); static void SwapValues(uCalc.Callback cb) { // Get the item handles for the two variables passed by reference var item1 = cb.ArgItem(1); var item2 = cb.ArgItem(2); // Use the item's DataType object to perform a highly efficient, pointer-based swap item1.DataType.SwapScalarValues(item1.ValueAddr(), item2.ValueAddr()); } // Define the Swap function with ByRef parameters uc.DefineFunction("Swap(ByHandle a, ByHandle b)", SwapValues); // Define the variables to be swapped uc.DefineVariable("x = 100"); uc.DefineVariable("y = 200"); Console.WriteLine($"Before: x = {uc.Eval("x")}, y = {uc.Eval("y")}"); // Call the swap function uc.Eval("Swap(x, y)"); Console.WriteLine($"After: x = {uc.Eval("x")}, y = {uc.Eval("y")}");