Skip to content

Commit 5f75829

Browse files
committed
Rebase and editorial changes
1 parent d643b63 commit 5f75829

File tree

1 file changed

+29
-16
lines changed

1 file changed

+29
-16
lines changed

reference/7.6/Microsoft.PowerShell.Core/About/about_Methods.md

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
description: Describes how to use methods to perform actions on objects in PowerShell.
33
Locale: en-US
4-
ms.date: 03/16/2022
4+
ms.date: 10/21/2025
55
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_methods?view=powershell-7.6&WT.mc_id=ps-gethelp
66
schema: 2.0.0
77
title: about_Methods
@@ -257,44 +257,57 @@ specific overload of the **Bar** method.
257257
int: 1
258258
```
259259

260-
## Finding what overload was used
260+
## Finding which overload was used
261261

262-
Since PowerShell 7.6, it is now possible to see what method overload was chosen
263-
by PowerShell. This is achieved through the new `MethodInvocation` tracing
264-
command.
262+
Beginning in PowerShell 7.6, you can see which method overload PowerShell chose
263+
by using `MethodInvocation` tracing.
265264

266-
This example shows how to use `Trace-Command` to display the overload chosen
267-
when calling the [String.Split method](/dotnet/api/system.string.split).
265+
The following examples use `Trace-Command` to display the overload chosen when
266+
calling the [String.Split method](xref:System.String.Split%2A).
268267

269268
```powershell
270269
Trace-Command -PSHost -Name MethodInvocation -Expression {
271270
"a 1 b 1 c 1 d".Split(1)
272271
}
272+
```
273+
274+
In the first example, the integer `1` was converted to a `[char]` instead of a
275+
`[string]`, which results in string being split by `[char]1` instead of the
276+
string `"1"`.
277+
278+
```Output
279+
DEBUG: ... MethodInvocation Information: 0 : Invoking method: string[] Spli
280+
t(char separator, System.StringSplitOptions options = System.StringSplitOpt
281+
ions.None)
282+
283+
a 1 b 1 c 1 d
284+
```
273285

286+
In the second example, the `Split()` method is called with the string `"1"`.
287+
288+
```powershell
274289
Trace-Command -PSHost -Name MethodInvocation -Expression {
275290
"a 1 b 1 c 1 d".Split("1")
276291
}
277292
```
278293

279-
```Output
280-
DEBUG: ... MethodInvocation Information: 0 : Invoking method: string[] Split(char separator, System.StringSplitOptions options = System.StringSplitOptions.None)
294+
PowerShell chose the overload that takes a `[string]` separator.
281295

282-
a 1 b 1 c 1 d
296+
```Output
297+
DEBUG: ... MethodInvocation Information: 0 : Invoking method: string[] Spli
298+
t(string separator, System.StringSplitOptions options = System.StringSplitO
299+
ptions.None)
283300
284-
DEBUG: ... MethodInvocation Information: 0 : Invoking method: string[] Split(string separator, System.StringSplitOptions options = System.StringSplitOptions.None)
285301
a
286302
b
287303
c
288304
d
289305
```
290306

291-
In the first example the `1` was casted as a `[char]` and not a string causing
292-
the split output to split by `[char]1` and not the character `"1"`.
293-
294307
## Using .NET methods that take filesystem paths
295308

296309
PowerShell supports multiple runspaces per process. Each runspace has its own
297-
_current directory_. This is not the same as the working directory of the
310+
_current directory_. This isn't the same as the working directory of the
298311
current process: `[System.Environment]::CurrentDirectory`.
299312

300313
.NET methods use the process working directory. PowerShell cmdlets use the
@@ -309,4 +322,4 @@ method.
309322
- [about_Member-Access_Enumeration](about_Member-Access_Enumeration.md)
310323
- [about_Properties](about_Properties.md)
311324
- [Get-Member](xref:Microsoft.PowerShell.Utility.Get-Member)
312-
- [Trace-Command](xref:Microsoft.PowerShell.Utility.Trace-Command)
325+
- [Trace-Command](xref:Microsoft.PowerShell.Utility.Trace-Command)

0 commit comments

Comments
 (0)