:::: MENU ::::

String Contains Method with StringComparison

if a string contains another string ignoring the case, there is no method available for string with ignore case

we can create extension to string using following !

public static bool Contains(this string original, string value, StringComparison comparisionType)
{
return original.IndexOf(value, comparisionType) >= 0;
}

Happy coding !


3 Comments

  • Reply Chirag Modh |

    “if a string contains another string ignoring the case, there is no method available for string with ignore case”

    you can do it by ToUpper or ToLower
    string original=abc;
    string value =A;
    original.ToUpper().Contains(value.ToUpper());

  • Reply Vinay Patel |

    Chirag , what i tried is to give extensions to Contains method .. to support case sensitivity.

    Thanks for comment

    • Reply snehaliteng |

      you are right vinay, there are extetion method we can create to make custome post . propreties in c# in vb.net

So, what do you think ?