我正在尝试将字符串变量连接到另一个字符串但我在变量之前和之后不断获得空格
objwriter.WriteLine("netsh int ipv4 Set address "+adaptername+" dhcp")
输出如下
netsh int ipv4 Set address Wi-Fi dhcp
我已经尝试了以下方法来连接字符串
objwriter.WriteLine("netsh int ipv4 Set address "& adaptername &" dhcp")
objwriter.WriteLine("netsh int ipv4 Set address "" & adaptername & "" dhcp")
答案 0 :(得分:2)
objwriter.WriteLine("netsh int ipv4 Set address " & adaptername.Trim() & " dhcp")
答案 1 :(得分:2)
尝试
<强> VB.Net 强>
objwriter.WriteLine("netsh int ipv4 Set address " & adaptername.Trim() & " dhcp")
C#
objwriter.WriteLine("netsh int ipv4 Set address " + adaptername.Trim() + " dhcp");