如何将数组元素添加到字符串 [英] How to add array elements to a string

查看:525
本文介绍了如何将数组元素添加到字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好



以下是我在阵列中获取元素的代码



Hi all

Below is the code where i am getting elements in array

$a=@($Split_ResultOfMasterListUser)

$a | Sort-Object | Get-Unique





以下是powershell控制台中的示例输出





below is the sample output in powershell console

root
sh506pa
snapp
sshd
su004sa
sys
tr005ma
trnadm
uucp
ve001na
vendabe
we002za
webm
webmd
wipftp
zapftp





现在我想将这些值分配给以逗号(,)加入的字符串



例如



now i want to assign these values to a string joining by comma(,)

e.g.

,nex3mzn,nex3slw,nex3orp,nex87vj,nex7uxw,nex7geg,nex7lmw,nex3hxf,nex8fas,root,bin,root,bin,sys,bin,adm,nuucp,uucp,





请告诉我怎么做。



Please tell me how to do this.

推荐答案

a = @(


Split_ResultOfMasterListUser)
Split_ResultOfMasterListUser)


a | Sort-Object | Get-Unique
a | Sort-Object | Get-Unique





以下是powershell控制台中的示例输出





below is the sample output in powershell console

root
sh506pa
snapp
sshd
su004sa
sys
tr005ma
trnadm
uucp
ve001na
vendabe
we002za
webm
webmd
wipftp
zapftp





现在我想将这些值分配给以逗号(,)加入的字符串



例如



now i want to assign these values to a string joining by comma(,)

e.g.

,nex3mzn,nex3slw,nex3orp,nex87vj,nex7uxw,nex7geg,nex7lmw,nex3hxf,nex8fas,root,bin,root,bin,sys,bin,adm,nuucp,uucp,





请告诉我怎么做。



Please tell me how to do this.


这篇关于如何将数组元素添加到字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆