向变量添加带双引号的字符串
本文关键字:字符串 变量 添加 | 更新日期: 2023-09-27 18:18:42
我有一个字符串像"Research Expenses: Itemize and follow <a href=" http://www.borenawards.org/boren_fellowship/budget.html" target="_blank">budget guidelines</a>(maximum $3,000)"
我想把这个值赋给一个字符串变量
string value= Research Expenses: Itemize and follow <a href=" http://www.borenawards.org/boren_fellowship/budget.html"
target="_blank">budget guidelines</a>(maximum $3,000);
我的需要是,无论字符串传递给它,我必须在双引号内显示内容。如何添加双引号?
我想显示像"Research Expenses: Itemize and follow <a href=" http://www.borenawards.org/boren_fellowship/budget.html" target="_blank">budget guidelines</a>(maximum $3,000)"
这样的字符串,请帮助我
你好,你可以使用转义序列:
string value= "Research Expenses: Itemize and follow <a href=" http://www.borenawards.org/boren_fellowship/budget.html"
target="_blank">budget guidelines</a>(maximum $3,000)";
你可以使用另一种方法,去掉双引号,用单引号代替,在末尾它们会很好:示例:
string value= "Research Expenses: Itemize and follow <a href=' http://www.borenawards.org/boren_fellowship/budget.html'
target='_blank'>budget guidelines</a>(maximum $3,000)";
你有两个选择,选择权在你。
好运。
如果您希望双引号包含在变量值中,则可以转义双引号,如下所示:
string str = "Research Expenses: Itemize and follow <a href='" http://www.borenawards.org/boren_fellowship/budget.html'" target='"_blank'">budget guidelines</a>(maximum $3,000)";
演示在字符串中将"替换为"
两种可能性:
- 用字符' 转义内部的"
"Research Expenses: Itemize and follow <a href='"http://www.borenawards.org/boren_fellowship/budget.html'" target='"_blank'">budget guidelines</a>(maximum $3,000)"
- 在字符串 中使用'代替'
"Research Expenses: Itemize and follow <a href='http://www.borenawards.org/boren_fellowship/budget.html' target='_blank'>budget guidelines</a>(maximum $3,000)"
string value= @"研究费用:逐项列出并遵循http://www.borenawards.org/boren_fellowship/budget.html" target="_blank">预算指南(最高3,000美元)";