// 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.Collections.Generic; namespace E { public class Program { private const int N = 25000000; public static void Main(string[] args) { string[] sa = { "A", "BB", "CCC", "DDDD", "EEEEE", "FFFFFF", "GGGGGGG" }; DateTime dt1 = DateTime.Now; for(int i = 0; i < N; i++) { string target = "Dddd"; if(!Array.Exists(sa, s => string.Compare(s, target, true) == 0)) throw new Exception("Ooops"); } DateTime dt2 = DateTime.Now; Console.WriteLine((dt2 - dt1).TotalSeconds); DateTime dt3 = DateTime.Now; for(int i = 0; i < N; i++) { string target = "Dddd"; target = target.ToLower(); if(!Array.Exists(sa, s => s.ToLower() == target)) throw new Exception("Ooops"); } DateTime dt4 = DateTime.Now; Console.WriteLine((dt4 - dt3).TotalSeconds); } } }