CSharp examples for System:String Case
Performs a case-insensitive comparison and returns true if equivalent.
using System.Text.RegularExpressions; using System.Text; using System.Linq; using System.Globalization; using System.ComponentModel; using System.Collections.Generic; using System;//from w ww .j a v a 2 s . c om public class Main{ /// <summary> /// Performs a case-insensitive comparison and returns true if equivalent. /// </summary> /// <param name="self"></param> /// <param name="compare"></param> /// <returns></returns> public static bool CaseInsensitiveEquals(this string self, params string[] compare) { foreach (var t in compare) { if (self == null && t == null) return true; if (self == null || t == null) return false; if (string.Equals(self, t, StringComparison.OrdinalIgnoreCase)) return true; } return false; } }