Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell有没有一种简单的方法可以将int 5转换为string 5或68转换为string 68?_Powershell - Fatal编程技术网

Powershell有没有一种简单的方法可以将int 5转换为string 5或68转换为string 68?

Powershell有没有一种简单的方法可以将int 5转换为string 5或68转换为string 68?,powershell,Powershell,我想知道是否有一种简单的方法可以把数字转换成单词,取9,再转换成9 这是关于.NET/C的问题;您可以将其放入一个类中,并在powershell中使用Add Type,使其正常工作 可能是这样(未经测试): $class=@” 公共类Num2Word { 公共静态字符串NumberToText(int n) { if(n

我想知道是否有一种简单的方法可以把数字转换成单词,取9,再转换成9

这是关于.NET/C的问题;您可以将其放入一个类中,并在powershell中使用
Add Type
,使其正常工作

可能是这样(未经测试):

$class=@”
公共类Num2Word
{
公共静态字符串NumberToText(int n)
{
if(n<0)
返回“减号”+数字文本(-n);
else如果(n==0)
返回“”;

否则,如果(n有一个名为.NET的优秀库可以做到这一点。我还没有尝试过这一点,但它似乎有一个适合它的库。我怀疑这将完全满足您的需要。

不,在PowerShell中没有内置的方法可以做到这一点。您必须编写自己的函数才能做到这一点。