This project is read-only.

Support for List of doubles etc.

Jul 25, 2010 at 11:49 PM
Edited Jul 25, 2010 at 11:49 PM


Hello, i noticed this thing didn't support collections of value types like doubles. 
These are common enough that they should probably be included.

The following code would work pretty well in supporting these.
It might not be as fast as array iteration but I'm betting in most cases this would be negligible.

public void WriteDataRecord(params object[] dataRecord) { dataRecord.AssertNotNull("dataRecord"); List<string> dataRecordAsStrings = new List<string>(); foreach (object od in dataRecord) { if (od == null) dataRecordAsStrings.Add(string.Empty); else if (od is IEnumerable<double>) /// TODO: support generic lists of value types foreach (double num in (IEnumerable<double>)od) dataRecordAsStrings.Add(num.ToString()); else dataRecordAsStrings.Add(od.ToString()); } WriteDataRecord(dataRecordAsStrings.ToArray()); }

Let me know what you think, thanks!