472,353 Members | 1,500 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,353 software developers and data experts.

Size of a class

Anybody know how to determine the "sizeof" a class?

TYIA

Jack

ja**********@netscape.NOSPAM.net
Nov 15 '05 #1
2 4011
sizeof( type )?

"Jack" <ja**********@netscape.net> wrote in message
news:#q**************@TK2MSFTNGP11.phx.gbl...
Anybody know how to determine the "sizeof" a class?

TYIA

Jack

ja**********@netscape.NOSPAM.net

Nov 15 '05 #2
Depending on what you want, specifically, there are a few answers.
For managed classes, there is no way to take the size of the class.
Conceptual class sizes are not set in stone in any way, a type can be of
many different sizes based on its contents. Considering both "One String"
and "A much longer string that has alot of extra words in it" are both of
type string, how do you determine size just by passing string? The header,
etc size should be determinable, but I don't know how much value that would
have for you, as you should rarely, if ever, be messing with such things.
You can, if you are really interested in the size of a given object graph at
a given point in time serialize it and determine the length of the output.
This may be transient however because other objects can be added or removed
at any time, or it may be downright incorrect because some values are tossed
out during serialization.
Value Types, structs in C#, that have no managed type members can have their
size retreived using sizeof(type) in unsafe C# code, and are the suggested
choice for interop, etc. Note however that arrays in structs are managed
objects. C# 2.0 is slated to introduce a feature that allows for fixed sized
inline valuetype arrays, but that is not here yet.
"Jack" <ja**********@netscape.net> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Anybody know how to determine the "sizeof" a class?

TYIA

Jack

ja**********@netscape.NOSPAM.net

Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

35
by: wired | last post by:
Hi, I've just taught myself C++, so I haven't learnt much about style or the like from any single source, and I'm quite styleless as a result....
4
by: vijay | last post by:
I have a doubt with size of classed with virtual functions I have declared A,A1,A2 ,B , C, D some classes with no varaibles but a vitual function...
18
by: Tarundeep | last post by:
hi, let us say it is a 32 bit processor then the size of the pointer is 32 bits. now i want to know what would be the size of the class with...
3
by: ThazKool | last post by:
Is there anyway to write a class or struct that has no storage. It only operates on a reference to an already existing type. This is actually an...
6
by: dddddddd2444444 | last post by:
Hi,please help... It works fine when I define a 2-D array like char code. But it won't work when I try to define the array dynamically using a...
6
by: Laurent | last post by:
Hello, This is probably a dumb question, but I just would like to understand how the C# compiler computes the size of the managed structure or...
45
by: charles.lobo | last post by:
Hi, I have recently begun using templates in C++ and have found it to be quite useful. However, hearing stories of code bloat and assorted...
18
by: Diogenes | last post by:
Hi All; I, like others, have been frustrated with designing forms that look and flow the same in both IE and Firefox. They simply did not scale...
11
by: mast2as | last post by:
This question has been posted to this forum before and I read the thread but found that the answers were perhaps imcomplete, so I am trying again....
6
by: webinfinite | last post by:
Hi, How to find a STL class size, for example: string. I would like to know what the size of the implementation of this class, I am not...
1
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.