Posts

Showing posts with the label csv

C#: How do I create a comma separated list from an object?

        public static string CreateCSVFromObject(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)        ...