Click here to Skip to main content
11,931,104 members (58,238 online)
Rate this:
Please Sign up or sign in to vote.
See more: C#
I want to know the answer of all three questions.

1)what is the size of Empty class?I think it is 0 Correct me

2) class a {
int a
string waqar
 // Abstract members and properties
    public abstract void RenameFolder();
    public abstract string FolderName
or you can take another example

3)Class b  
virtual void shape(
//method body

& also what is the size of the class in #2 & #3

[Edited]Code is wrapped in "pre" tags[/Edited]
Posted 18-Aug-11 9:22am
Edited 18-Aug-11 9:45am
tamerqatar 18-Aug-11 14:46pm
you mean the size of the file o the hard disk??? just you can check after creating the class file in your project folder...
Smithers-Jones 18-Aug-11 15:33pm
Posted as solution by Ali Waquar: "no ,, in memory.. some one asked me these question.. i want to know that how much i was rite..." - Don't post "fake" solutions, post either a comment or improve your question.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Why should an empty class be zero bytes? A class does not really have a size at all, except in terms of an instance - and a class instance variable will always return 4 or 8 as the size (the size of a pointer to the actual instance).

An empty class isn't empty anyway: it has a name, it is associated with a namespace, it has an inheritance (from Object if nothing else), it may have properties, fields, members. Since these can be retrieved by reflection they must be stored somewhere, and so should (probably) be included in the class "size".

Have a look at google - there is some interesting discussion on class size, and what it actually is! It's not as easy as you think...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.151126.1 | Last Updated 18 Aug 2011
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100