Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static string ObjectToCsvData(object obj)
- {
- if (obj == null)
- {
- throw new ArgumentNullException("obj", "Value can not be null or Nothing!");
- }
- StringBuilder sb = new StringBuilder();
- Type t = obj.GetType();
- PropertyInfo[] pi = t.GetProperties();
- for (int index = 0; index < pi.Length; index++)
- {
- sb.Append(pi[index].GetValue(obj, null));
- if (index < pi.Length - 1)
- {
- sb.Append(",");
- }
- }
- return sb.ToString();
- }
Add Comment
Please, Sign In to add comment