// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Text; class MainClass { public static string makeids(string tbl) { StringBuilder sb = new StringBuilder(); int oldix = 0; int ix = 0; int n = 0; while((ix = tbl.IndexOf("", oldix)) >= 0) { n++; sb.Append(tbl.Substring(oldix, ix - oldix)); sb.Append(""); oldix = ix + "".Length; } sb.Append(tbl.Substring(oldix)); return sb.ToString(); } public static void Main(string[] args) { Console.WriteLine(makeids("aaa")); Console.WriteLine(makeids("aaabbbcccdddeee")); Console.WriteLine(makeids("aaabbb")); Console.WriteLine(makeids("aaa")); Console.WriteLine(makeids("")); } }