How type conversion works

$s = "VMS";
$OFS = "";
[string] [char[]] ([int[]] [char[]] $s | foreach{$_+1})

 

Output: WNT

$OFS (Output Field Separator): When PowerShell converts arrays to strings, it takes each array element, converts that element into a string, and then concatenates all the pieces together. Because this would be an unreadable mess, it inserts a separator between each element. That separator is specified using the $OFS variable. It can be set to anything you want, even the empty string.

posted @ 2012-12-30 00:38  HelloWorld.Michael  阅读(142)  评论(0编辑  收藏  举报