Does DataTable
in C# provide a property that gives me the size of each row (number of bytes)?
Asked
Active
Viewed 3,342 times
3

TheTXI
- 37,429
- 10
- 86
- 110
-
1What specifically do you mean by "row size"? The size the row *could* have with the data types (ie. a varchar(40) takes 40 or 80 bytes (unicode or not)), or the actual size (an empty string doesn't take any size)? – Lasse V. Karlsen May 14 '09 at 18:50
-
1yes. Row size of each row in bytes. – May 14 '09 at 18:53
-
So by "row size" you mean "row size". ok... – Lasse V. Karlsen May 14 '09 at 19:00
1 Answers
-3
You can determine the unmanaged size of a managed object with Marshal.SizeOf.

JP Alioto
- 44,864
- 6
- 88
- 112
-
Nice idea, I didn't know about Marshal.SizeOf() but it doesn't work in this case. I just tried this but it throws an argument exception if you call Marshal.SizeOf() with an argument of type DataRow, with the detail "cannot be marshaled as an unmanaged structure; no meaningful size or offset can be computed". – Ben Robbins Aug 01 '11 at 05:55