// 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; class MainClass { public static void Main(string[] args) { string str = "abc def abc def abc def"; string fnd = "abc"; int offset = 0; int ix; while((ix = str.IndexOf(fnd, offset)) >= 0) { Console.WriteLine(ix); offset = ix + fnd.Length; } } }