Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# size
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
    { 
      get;
      set;
    }
}
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
Ali_1001.3K
Edited 18-Aug-11 9:45am
v3
Comments
tamerqatar at 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 at 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
good
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...
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 325
1 DamithSL 300
2 Sergey Alexandrovich Kryukov 289
3 CPallini 235
4 Maciej Los 215
0 OriginalGriff 5,455
1 DamithSL 4,422
2 Maciej Los 3,860
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,010


Advertise | Privacy | Mobile
Web02 | 2.8.141216.1 | Last Updated 18 Aug 2011
Copyright © CodeProject, 1999-2014
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