|
-
Oct 26th, 2007, 02:52 PM
#1
getting the size of a structure?
what if you have a structure like this:
struct foo
{
public int A;
public char[] B;
}
the size of the structure obviously changes depending on the size of the char array inside it. Is there a "correct" way to get the size of the struct so that it would include the size of the character array?
sizeof() obviously will not work... i could check the length of the array at runtime to get the size of the struct, but i was just wondering if there is a function for doing this already
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Oct 26th, 2007, 02:58 PM
#2
Re: getting the size of a structure?
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Oct 26th, 2007, 03:01 PM
#3
Re: getting the size of a structure?
hmm actually for some reason Marshall.SizeOf() seems to only count 4 bytes for the character array regardless of how many items it has in it
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Oct 26th, 2007, 10:02 PM
#4
Re: getting the size of a structure?
The size of that structure does NOT change depending on the size of the array. Arrays are reference type objects, so the structure only contains a reference to the array. That reference is 32-bits no matter how many elements the array has. If you want the size of the array then you need to multiply its Length by the size of its element type.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|