title: .Net: Is there a better way to check object's property for null or empty string?
body: <p>I'm using FileHelper to generate object's property. Here is an example of one property:</p>
  
  <pre><code>&lt;FieldOptional(), _
   FieldTrim(TrimMode.Both)&gt; _
   &lt;FieldNullValue(GetType(String), " ")&gt; _
  Public StoreNo As String
  </code></pre>
  
  <p>As you can see the StoreNo will either have a value or " ", one of the business policy is to check if the StoreNo is empty or nothing if the object's StoreNo is empty or null then the record will not create.</p>
  
  <p>I though about creating an HasValue Function in the class to check the StoreNo and other properties in the object but I feel like it is a hack.</p>
  
  <pre><code>Public Function HasValue() As Boolean
  
      Dim _HasValue As Boolean = True
  
      If StringHelper.IsNullOrBlank(Me.StoreNo) Then
          _HasValue = False
      End If
  
      Return _HasValue
  End Function
  </code></pre>
  
  <p>I don't think this approach is an ideal solution. what if the StoreNo is remove or change to something else. What's the best approach to check object's property?</p>