.NET - Convert Generic Collection to DataTable

前端 未结 5 1694
感情败类
感情败类 2020-11-27 10:17

I am trying to convert a generic collection (List) to a DataTable. I found the following code to help me do this:

// Sorry about indentation
public class Col         


        
5条回答
  •  情深已故
    2020-11-27 11:08

    If Nullable.GetUnderlyingType() given your prop.PropertyType returns a not-null value, use that as the type of a column. Otherwise, use prop.PropertyType itself.

提交回复
热议问题