title: How to check all properties of an class whether null or empty?
body: <p>i need a method to check the all class properties for null value and if just one of the properties is null then return false. something like this:</p>
  
  <pre><code>public static bool Check&lt;T&gt;(T instance)
  {
      foreach (var parameter in instance)
      {
          if (parameter == null)
              return false;
      }
  
      return true;
  }
  </code></pre>
  
  <p>how can i do it?</p>
  
  <p><strong><em>Update</em></strong>:
  its not a duplicate question!!!. i already saw this <a href="https://stackoverflow.com/questions/22683040/how-to-check-all-properties-of-an-object-whether-null-or-empty">link</a> and the different is my class properties has different types (<code>string</code>, <code>int</code>, <code>double</code> ....). so i need a method to check them out to. here is one of my classes(some of them just have fields.)</p>
  
  <pre><code>public class WS_IN_SimpayTransaction
  {
      [DataMember]
      public WS_IN_WebServiceIdentity wsIdentity;
      [DataMember]
      public WS_IN_SimpayTransactionParams simpayTransactionParams;
  }
  public class WS_IN_WebServiceIdentity
  {
      private string WS_userName;
      private string WS_passWord;
  
      public string WS_UserName
      {
          set { this.WS_userName = value; }
          get { return this.WS_userName; }
      }
      public string WS_PassWord
      {
          set { this.WS_passWord = value; }
          get { return this.WS_passWord; }
      }
  }
  public class WS_IN_SimpayTransactionParams
  {
          string amount;
          string itemDes;
          string productID;
          string mobileNumber;
          string bankType;
          double bankTransactionID;
          int transID;
          DateTime date;
          public string Amount
          {
              set { amount = value; }
              get { return amount; }
          }
          public string ItemDes
          {
              set { itemDes = value; }
              get { return itemDes; }
          }
          public string ProductID
          {
              set { productID = value; }
              get { return productID; }
          }
          public string MobileNumber
          {
              set { mobileNumber = value; }
              get { return mobileNumber; }
          }
          public string BankType
          {
              set { bankType = value; }
              get { return bankType; }
          }
          public double BankTransactionID
          {
              set { bankTransactionID = value; }
              get { return bankTransactionID; }
          }
          public int TransID
          {
              set { transID = value; }
              get { return transID; }
          }
          public DateTime Date
          {
              set { date = value; }
              get { return date; }
          }
  }
  </code></pre>
  
  <p>long story short. its a little complicated.</p>