Checking for string contents? string Length Vs Empty String

前端 未结 13 927
野趣味
野趣味 2020-12-17 10:14

Which is more efficient for the compiler and the best practice for checking whether a string is blank?

  1. Checking whether the length of the string == 0
13条回答
  •  心在旅途
    2020-12-17 10:41

    Actually, IMO the best way to determine is the IsNullOrEmpty() method of the string class.

    http://msdn.microsoft.com/en-us/library/system.string.isnullorempty.

    Update: I assumed .Net, in other languages, this might be different.

提交回复
热议问题