Home [C# 筆記] IsNullOrEmpty、IsNullOrWhiteSpace
Post
Cancel

[C# 筆記] IsNullOrEmpty、IsNullOrWhiteSpace

String.IsNullOrEmpty

關於 String.IsNullOrEmpty
表示指定的字串是否為 null空字串 ("")

  • 參數:欲檢驗的字串
  • 回傳值:Boolean
  • 從 .NET Framework 2.0 開始加入
  • 用來檢驗傳入參數是否為 null空字串 的方法

String.IsNullOrWhiteSpace

關於 String.IsNullOrWhiteSpace
表示指定的字串是否為 null空白,或只由空白字元組成的字串

  • 參數:欲檢驗的字串
  • 回傳值:Boolean
  • 從 .NET Framework 4.0 開始加入
  • 用來檢驗傳入參數是否為 null空字串只有空白符號 的方法

MSDN - String.IsNullOrWhiteSpace(String) 方法
MSDN - String.IsNullOrEmpty(String) 方法
https://blog.yowko.com/string-isnullorempty-isnullorwhitespace/

This post is licensed under CC BY 4.0 by the author.