如何在string.Format方法中输出大括号({})
生活随笔
收集整理的這篇文章主要介紹了
如何在string.Format方法中输出大括号({})
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
C#(a.cs)
using System;public class Test {public void Middle(string start, string end){string pat1 = string.Format("(?<={0}).*(?={1})", start, end);Console.WriteLine(pat1);string pat2 = string.Format("(?<={{0}}).*(?={{1}})", start, end);Console.WriteLine(pat2);string pat3 = string.Format("(?<={{{0}}}).*(?={{{1}}})", start, end);Console.WriteLine(pat3);}public static void Main(string[] args){string start = "12";string end = "35";Test t = new Test();t.Middle(start, end);} }編譯運行: E:\>csc a.cs Microsoft(R) Visual C# 2010 編譯器 4.0.30319.1 版 版權所有(C) Microsoft Corporation。保留所有權利。E:\>a.exe (?<=12).*(?=35) (?<={0}).*(?={1}) (?<={12}).*(?={35})E:\>
結論: {{ 得到 { , }} 得到 }
更多信息可參考:http://msdn.microsoft.com/zh-cn/library/txafckwd.aspx
總結
以上是生活随笔為你收集整理的如何在string.Format方法中输出大括号({})的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 优酷下载的会员独享KUX视频格式怎么转换
- 下一篇: BZOJ3019 : [Balkan20