Type Shortcuts

PowerShell Team

PSMDTAG:FAQ: What is a TYPE SHORTCUT?
PSMDTAG:FAQ: What are the TYPE SHORTCUTS?

 

Type shortcuts are a Windows PowerShell feature that allows you to reduce the amount of typing you have to do when specifying a type. 

 

For example, the following 2 statements produce the same result:

[System.Text.RegularExpressions.Regex]”^c.*”

[Regex]”^c.*”

 

Jim Truher produced the following list of type shortcuts available in V1.0 (NOTE: The WMI ones will be available in RC2 as noted in: http://blogs.msdn.com/powershell/archive/2006/06/26/647038.aspx )

 

 

[int]         typeof(int)
[int[]]       typeof(int[])
[long]        typeof(long)
[long[]]      typeof(long[])
[string]      typeof(string)
[string[]]    typeof(string[])
[char]        typeof(char)
[char[]]      typeof(char[])
[bool]        typeof(bool)
[bool[]]      typeof(bool[])
[byte]        typeof(byte)
[double]      typeof(double)
[decimal]     typeof(decimal)
[float]       typeof(float)
[single]      typeof(float)
[regex]       typeof(System.Text.RegularExpressions.Regex)
[array]       typeof(System.Array)
[xml]         typeof(System.Xml.XmlDocument)
[scriptblock] typeof(System.Management.Automation.ScriptBlock)
[switch]      typeof(System.Management.Automation.SwitchParameter)
[hashtable]   typeof(System.Collections.Hashtable)
[type]        typeof(System.Type)
[ref]         typeof(System.Management.Automation.PSReference)
[psobject]    typeof(System.Management.Automation.PSObject)
[wmi]         typeof(System.Management.ManagementObject)
[wmisearcher] typeof(System.Management.ManagementObjectSearcher)
[wmiclass]    typeof(System.Management.ManagementClass)

 

Jeffrey Snover [MSFT]
Windows PowerShell/Aspen Architect
Visit the Windows PowerShell Team blog at:    http://blogs.msdn.com/PowerShell
Visit the Windows PowerShell ScriptCenter at:  http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx

 

PSMTAG:DOTNET: Language shortcuts for type specifications

PSMTAG:LANGUAGE: Language shortcuts for type specifications

0 comments

Discussion is closed.

Feedback usabilla icon