IsBlank() публичный статический Метод

Checks if a String is whitespace, empty ("") or null.
 StringUtil.IsBlank(null)      = true StringUtil.IsBlank("")        = true StringUtil.IsBlank(" ")       = true StringUtil.IsBlank("bob")     = false StringUtil.IsBlank("  bob  ") = false 
public static IsBlank ( string val ) : bool
val string /// the String to check, may be null ///
Результат bool
Пример #1
0
 /// <summary>
 /// Throws <see cref="ArgumentException" /> if the parameter <paramref name="o"/>
 /// is <code>null</code> or blank.
 /// </summary>
 /// <param name="o">value to test for blank.</param>
 /// <param name="param">name of the parameter to check.</param>
 /// <exception cref="ArgumentException">if <paramref name="o"/> is <code>null</code> or  blank and constructs a
 /// message with the name of the parameter.</exception>
 public static void BlankCheck(String o, String param)
 {
     if (StringUtil.IsBlank(o))
     {
         throw new ArgumentException(String.Format(BLANK_FORMAT, param));
     }
 }
Пример #2
0
 /// <summary>
 /// Throws <see cref="ArgumentException" /> if the parameter <paramref name="o"/>
 /// is <code>null</code> or blank, otherwise returns its value.
 /// </summary>
 /// <param name="o">value to test for blank.</param>
 /// <param name="param">name of the parameter to check.</param>
 /// <returns>the value of the parameter <paramref name="o"/>.</returns>
 /// <exception cref="ArgumentException">if <paramref name="o"/> is <code>null</code> or  blank and constructs a
 /// message with the name of the parameter.</exception>
 public static String BlankChecked(String o, String param)
 {
     // Avoid calling BlankCheck() here to reuse code: it deepens the stack trace.
     // We want the exception to be thrown as close to the call site as possible.
     if (StringUtil.IsBlank(o))
     {
         throw new ArgumentException(String.Format(BLANK_FORMAT, param));
     }
     return(o);
 }
 /// <summary>
 /// Determines if the string parameter 'str' ends with the character value.
 /// </summary>
 /// <param name="str">
 ///            String to check for the character at the end. </param>
 /// <param name="value">
 ///            The character to look for at the end of the string. </param>
 /// <returns> true if character parameter is found at the end of the string
 ///         parameter otherwise false. </returns>
 public static bool EndsWith(string str, char value)
 {
     return(StringUtil.IsBlank(str) ? false : str[str.Length - 1] == value);
 }