Created
August 22, 2018 14:20
-
-
Save chrisswong/19124d1e07fdf4953981979bf785e575 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace ConsoleApp2 | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
string s = "abcd %(dbac) acd"; | |
var dict = new Dictionary<string, object>(); | |
dict.Add("dbac", 124); | |
Console.WriteLine( RepalceTokenString(s, dict)); | |
Console.ReadLine(); | |
} | |
static string RepalceTokenString(string s, Dictionary<string, object> dict) | |
{ | |
foreach (var item in dict) | |
{ | |
string token = "%(" + item.Key + ")"; | |
s = s.Replace(token, item.Value.ToString()); | |
} | |
return s; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment