How can I view the memory address of the underlying object referenced by a variable in Powershell?
In C# I can do something like below but not sure how to do the equivalent in Powershell
int i;
int* pi = &i;
The reason for this is because of this below example giving different results depending on whether the script-block was dot-sourced or used the call-operator. The variable name is the same and when dot-sourced the updated value remains after the script-block has exited. This got me wondering if the call-operator implementation works on copies of the variables while the dot-source implementation is using the original variables.
PS C:\> $n = 1;&{$n = 2};$n
1
PS C:\> $n = 1;.{$n = 2};$n
2
If I could do something like this it might help me understand whats happening...
PS C:\> $n = 1;&{$n.GetMemoryAddress()};
##########
PS C:\> $n = 1;.{$n.GetMemoryAddress()};
##########