Guest User

Untitled

a guest
Jan 23rd, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. public static string ObjectToCsvData(object obj)
  2. {
  3. if (obj == null)
  4. {
  5. throw new ArgumentNullException("obj", "Value can not be null or Nothing!");
  6. }
  7.  
  8. StringBuilder sb = new StringBuilder();
  9. Type t = obj.GetType();
  10. PropertyInfo[] pi = t.GetProperties();
  11.  
  12. for (int index = 0; index < pi.Length; index++)
  13. {
  14. sb.Append(pi[index].GetValue(obj, null));
  15.  
  16. if (index < pi.Length - 1)
  17. {
  18. sb.Append(",");
  19. }
  20. }
  21.  
  22. return sb.ToString();
  23. }
Add Comment
Please, Sign In to add comment