ExtensionMethod.NET Home of 880 C#, Visual Basic, F# and Javascript extension methods

DoesNotStartWith

It returns true if string does not start with the character otherwise returns false if you pass null or empty string, false will be returned.

Source

public static bool DoesNotStartWith(this string input, string pattern)
{
   return string.IsNullOrEmpty(pattern) ||
          input.IsNullOrEmptyOrWhiteSpace() ||
          !input.StartsWith(pattern, StringComparison.CurrentCulture);
}

Example

Assert.IsTrue("Test".DoesNotStartWith('?'));

Author: Omkar Panhalkar

Submitted on: 7 mei 2012

Language: C#

Type: System.String

Views: 4968