c# - Replace repeated char with something else in a string -


I need help in understanding a logic:

So, suppose I have a string , And whenever there is a character repeated within string , I have to replace it with ( four + serial number ).

For example:

Original string: "abcdefgabfabc"

expected output: "abcdefga2b2f2a3b3c2"

'A' is 3 times, so 'A' remains in the form of 'A', but the second 'A' becomes 'A2' , And the third gets 'A' 'A3'. It also goes to other characters like B, B2, B3 ...

< Div class = "post-text" itemprop = "text">

  var str = "abcdefgabfabc"; Var character = str. Selection ((c, index) => {int count = str.Substring (0, index) .net (x = & gt; c == x); if (calculation> 0) return c ToString () + (Count + 1); and return c.ToString ();}). SelectMon (c => gt) .Oir (); Var result = new string (character); // abcdefga2b2f2a3b3c2  

Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -