c# - How to read each character in string and replace with urdu characters -


this question has answer here:

this different approach different question, it's not arabic it's urdu. it's not date time it's string.

i want read each character in string , replace urdu characters.

for example:

string amount = "100"; 

i want read each string.

if 1 should replace urdu character ١
if 0 should replace urdu character ٠

and end result of ١٠٠

how can break down, tried using this:

var output = ""; foreach (char c in str) {     if (c == 1)      {          output = "١";           }      output += c; } 

i want concatenate characters.

i suggest using dictionary<char, char> substitutions; string.concat concatenation:

 dictionary<char, char> urdu = new dictionary<char, char>() {    {'0', '١'},    {'1', '٠'},    //todo: add other pairs here  };   ...   string source = "100";   char u;   string result = string.concat(source.select(c => urdu.trygetvalue(c, out u) ? u : c)); 

Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -