
How to print braces {} in C#
The brace is a special character in C#. It cannot be input like ordinary characters, nor can it be print with a transfer character(\). Instead, it should be print like this {{}}. The following is a specific example:
Output Javascript code in C#
Aspx file:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="outputdakuohao.aspx.cs" Inherits="testpro.utputdakuohao" %>
<!DOCTYPE html>
<html>
<head runat="server">
<title>How to print braces in C#</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Literal ID="test" runat="server" />
</div>
</form>
</body>
</html>
CS file:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace testpro
{
public partial class outputdakuohao : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
test.Text = "<script type='text/javascript'>function output(){{alert('Print braces!');}}output();</script>";
}
}
}
After passing the test in Visual Studio. create a new file, copy the code into it, and run it directly.
-
Related Reading
- C# listview select row(a row and multiple rows)
- Solve the flickering problem of C# listview multithr
- C# convert punctuation marks to Unicode encoding
- C# Read and write to text file Newline, with one lin
- C# merge binary array(byte array)
- C# hashtable synchronized and SyncRoot(cost comparis
- C# gridview checkbox cannot get value(reason and sol
- C# Winform button transparent background with proper
- Error cs1010 newline in constant - .net(C#) mislabel
- C# datetime difference(year, month, day, hour, minut
- Convert Unicode to string C#(with string to unicode)
- C# Why does the generated random number repeat and g