I have this string in vb.net.开发者_开发问答 I would appreciate if you can let me know how I can enclose the values in double quotes
dim str as string=""
str.Append("EmpID=" & empNo & " DeptID=" & deptID & "")
I want the value of string to be EmiID="10" DeptID="20"
Use double double quotes to get a single double quote in the string
str.Append("EmpID=""" & empNo & """ DeptID=""" & deptID & """")
ControlChars.Quote is nice to use :)
dim metatransferString as string = ""
Just use double double quotes like:
dim str as string=""
str.Append("EmpID=""" & empNo & """ DeptID=""" & deptID & """")
Use ControlChars.Quote
dim str as string=""
str.Append("EmpID=" & cControlChars.Quote & empNo & ControlChars.Quote & " DeptID=" & ControlChars.Quote & deptID & ControlChars.Quote)
I know it is a pretty old question. But I used it this way
str.Append(String.Format("EmpID={0}{1}{0} DeptID={0}{2}{0}", Chr(34), empNo, deptID))
If empNo = 10 DeptID = 20, it would give EmpId="10" DeptID="20"
精彩评论