Introduction:
Using
\" we can concatenate double quotes ("") with the string in C#
and using """" we can concatenate double quotes
("") with the string in VB. Suppose you have a string variable
strName having string value "Asp.net" and on print it will print as
Asp.net without apostrophe but if you want to print it as “Asp.net” i.e. in
apostrophe then you have to concatenate your string with double quotes on both sides. But if you write as we
normally do to concatenate like:
C#.NET Code
C#.NET Code
In the code behind file(.aspx.cs) write following
code on Button click or any event as per your application requirement
protected
void Button1_Click(object sender, EventArgs e)
{
string strName = "Asp.net";
string newStr=""" + strName + """'; // it will not work. so comment this line and write as below:
string newStr="\"" + strName + "\"";
Response.Write(newStr); //it will print "Asp.net"
}
VB.NET Code
- In the code behind file(.aspx.vb) write
following code on Button click or any event as per your application
requirement
Protected
Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim strName As String = "Asp.net"
Dim newStr As String = """" & strName &
""""
Response.Write(newStr)
End Sub
0 comments:
Post a Comment