Connect with Expertise | Find Experts, Get Answers, Share Insights

Object Size

thejackofall
 
Posts: n/a
#1: Aug 25 '05
Hi.

How do I get the size of the object at runtime? I tried Marshal.SizeOf, but
it fails with ArgumentException.

Suppose I want to do the following:

DataSet oDS = new DataSet();
// Get the size of oDS

Thanks.
J

--
Be Cool!

Daniel O'Connell [C# MVP]
 
Posts: n/a
#2: Aug 25 '05

re: Object Size



"thejackofall" <thejackofall@discussions.microsoft.com> wrote in message
news:11B50F79-2DAB-4830-AC5E-BFF4350AE5C8@microsoft.com...[color=blue]
> Hi.
>
> How do I get the size of the object at runtime? I tried Marshal.SizeOf,
> but
> it fails with ArgumentException.
>
> Suppose I want to do the following:
>
> DataSet oDS = new DataSet();
> // Get the size of oDS[/color]

There is no real way to get the size of an object tree at runtime, which is
waht I assume you want to do. Marshal.SizeOf returns the marshalled size
which is an inefficent estimate.





thejackofall
 
Posts: n/a
#3: Aug 25 '05

re: Object Size


I am looking something equivalent to the sizeof() in C++.

With it, i can get the exact size of the object at runtime.

Thanks.
J

--
Be Cool!


"Daniel O'Connell [C# MVP]" wrote:
[color=blue]
>
> "thejackofall" <thejackofall@discussions.microsoft.com> wrote in message
> news:11B50F79-2DAB-4830-AC5E-BFF4350AE5C8@microsoft.com...[color=green]
> > Hi.
> >
> > How do I get the size of the object at runtime? I tried Marshal.SizeOf,
> > but
> > it fails with ArgumentException.
> >
> > Suppose I want to do the following:
> >
> > DataSet oDS = new DataSet();
> > // Get the size of oDS[/color]
>
> There is no real way to get the size of an object tree at runtime, which is
> waht I assume you want to do. Marshal.SizeOf returns the marshalled size
> which is an inefficent estimate.
>
>
>
>
>
>[/color]
Closed Thread