{ public static bool ContainsEx(this string me, string other) { if(me == null || other == null) return false; // This is a better way of performing a case-insensitive Contains return me.IndexOf(other, 0, StringComparison.OrdinalIgnoreCase) != -1; } } ...
public class CaseInsensitiveComparer : IComparer<string> { public int Compare(string x, string y) { return string.Compare(x, y, true); } } public void Linq31() { string[] words = { "aPPLE", "AbAcUs", "bRaNcH", "BlUeBeRrY", "ClOvEr", "cHeRry"}; var sortedWords = words.OrderBy...
publicint Compare(string x, string y) { returnstring.Compare(x, y, true); } } publicvoid Linq34() { string[] words = { "aPPLE", "AbAcUs", "bRaNcH", "BlUeBeRrY", "ClOvEr", "cHeRry"}; var sortedWords = words.OrderByDescending(a => a, new CaseInsensitiveComparer()); ObjectDumper...
LINQ Where Case Statement Linq Where Clause (on class that has an [array]) LINQ Where DateTime Contains String Linq with Count and Group By Linq: multiple sub joins or sub-queries Load Data Fast Load Entity data model from xml Local sequence cannot be used in LINQ to SQL implementations of...
string query = string.Empty; query = "searchString"; string path = Server.MapPath("~/contacts.xml"); XDocument xd = XDocument.Load(path); var results = (from items in xd.Elements("Company").Elements("Contact") where items.Element("Name").Value.ToLowerInvariant().Contains(query.ToLowerInv...
public class CaseInsensitiveComparer : IComparer<string> { public int Compare(string x, string y) { return string.Compare(x, y, true); } } public static void ThenByDescendingEx1() { string[] fruits = { "apPLe", "baNanA", "apple", "APple", "orange", "BAnana", "ORANGE", "apPLE" ...
In the where clause of this query, both int.Parse and string. Contains are used to help filter messages: int.Parse(msg.Label) > 5 && msg.Body.ToString().Contains('CSharpRecipes.D') Finally, the orderby is used to sort the results in descending order: orderby msg.Body.ToString() ...
For example, you might have a class named Person that contains a property named FavoriteCities that returns an array of string values. In that case, you set the ContextTypeName property to Person and set the TableName property to FavoriteCities....
//c# public void Linq31() { string[] words = { "aPPLE", "AbAcUs", "bRaNcH", "BlUeBeRrY", "ClOvEr", "cHeRry" }; var sortedWords = words.OrderBy(a => a, new CaseInsensitiveComparer()); ObjectDumper.Write(sortedWords); } ;;clojure (defn linq31 [] (let [words ["aPPLE" "AbAcU...
//java public static void Linq31() { var words = new String[] { "aPPLE", "AbAcUs", "bRaNcH", "BlUeBeRrY", "ClOvEr", "cHeRry" }; var sortedWords = Arrays.stream(words). sorted(Comparator.comparing(String::toString, String.CASE_INSENSITIVE_ORDER)); sortedWords.forEach(System.out::pri...