Replace values ​​in double quotes in VB.net

I have this line in vb.net. I would appreciate if you could tell me how I can enclose values ​​in double quotes

dim str as string="" str.Append("EmpID=" & empNo & " DeptID=" & deptID & "") 

I want the string value to be EmiID = "10" DeptID = "20"

+4
source share
5 answers

Use double double quotes to get one double quote in a string

 str.Append("EmpID=""" & empNo & """ DeptID=""" & deptID & """") 
+6
source

ControlChars.Quote is nice to use :)

dim metatransferString as string = ""

+3
source

Just use double double quotes, for example:

 dim str as string="" str.Append("EmpID=""" & empNo & """ DeptID=""" & deptID & """") 
+2
source

Use ControlChars.Quote

 dim str as string="" str.Append("EmpID=" & cControlChars.Quote & empNo & ControlChars.Quote & " DeptID=" & ControlChars.Quote & deptID & ControlChars.Quote) 
+2
source

I know this is a pretty old question. But I used it that way

 str.Append(String.Format("EmpID={0}{1}{0} DeptID={0}{2}{0}", Chr(34), empNo, deptID)) 

If empNo = 10 DeptID = 20, this will give EmpId = "10" DeptID = "20"

0
source

Source: https://habr.com/ru/post/1305490/


All Articles