1

I am trying to concat a string variable into another string but I keep getting white spaces before and after the variable

objwriter.WriteLine("netsh int ipv4 Set address "+adaptername+" dhcp")

Output is the following

netsh int ipv4 Set address  Wi-Fi  dhcp

I have tried the following methods to concat the string also

objwriter.WriteLine("netsh int ipv4 Set address "& adaptername &" dhcp") objwriter.WriteLine("netsh int ipv4 Set address "" & adaptername & "" dhcp")

2
  • It would be really helpful if you give me some resource to read up on how string concatenation works in vb.net Commented Dec 19, 2013 at 10:27
  • 1
    Replace this adaptername with adaptername.Trim() Commented Dec 19, 2013 at 10:29

2 Answers 2

2

TRY THIS

VB.Net

objwriter.WriteLine("netsh int ipv4 Set address " &  adaptername.Trim() & " dhcp")

C#

objwriter.WriteLine("netsh int ipv4 Set address " +  adaptername.Trim() + " dhcp");
Sign up to request clarification or add additional context in comments.

Comments

2
objwriter.WriteLine("netsh int ipv4 Set address " & adaptername.Trim() & " dhcp")

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.