himanshu
himanshu

Reputation: 41

What should be the VB.NET equivalent of below C# code?

//Insert new url in the image tag
src = "src=\"" + context.Request.Url.Scheme + "://" + context.Request.Url.Authority + src + "\"";

Receiving Syntax error at "://" while converting from C# to to VB.NET.

Upvotes: 0

Views: 66

Answers (2)

Dai
Dai

Reputation: 155145

As @Olvarsham's answer puts, VB escapes double-quotes by doubling them.

However I feel it would be cleaner to rewrite the expression as a format-string:

src = String.Format("src=""{0}://{1}{2}""", context.Request.Url.Scheme, context.Request.Url.Authority, src)

If you reference context.Request.Url above, it gets simpler:

Dim url As Url = context.Request.Url
src = String.Format("src=""{0}://{1}{2}""", url.Scheme, url.Authority, src)

Upvotes: 3

Olivarsham
Olivarsham

Reputation: 1731

The escape sequence in VB.NET is by doubling the double-quotes.

src = "src=""" + context.Request.Url.Scheme + "://" + context.Request.Url.Authority + src + "\"""

Upvotes: 2

Related Questions