Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7831129
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T11:35:02+00:00 2026-06-02T11:35:02+00:00

Imagine I have two classes, class1 and class2. Class1 inherits from baseClass, which looks

  • 0

Imagine I have two classes, class1 and class2.

Class1 inherits from baseClass, which looks like so:

baseClass
{
private Int64 one;
protected Int64 two;
public Int64 three;
}

and class1 looks like this

Class1 : baseClass
{
private Int64 four;
protected Int64 five;
public Int64 six;
}

and class2 looks like this:

Class2
{
private Int64 one;
protected Int64 two;
public Int64 three;
private Int64 four;
protected Int64 five;
public Int64 six;
}

If I were to create arrays of 10k of each class, which would be larger? Would the class1 array be larger because class1 would also contain some sort of meta data to do with baseClass? Otherwise their properties are identical, so technically they should be the same.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T11:35:04+00:00Added an answer on June 2, 2026 at 11:35 am

    Given two arrays of reference types, that is:

    Class1[] a1 = new Class1[10000];
    Class2[] a2 = new Class2[10000];
    

    The arrays will be exactly the same size. The elements of the arrays are just references, and a reference is always the same size, regardless of the object to which it’s referring. A reference is 4 bytes in the 32-bit runtime, and 8 bytes in the 64-bit runtime.

    As for the class instances, I would expect them to be identical in size, as well. The class instance itself only holds the data for the class, and a small amount of other data that includes a reference to the type for that class. The class instance itself doesn’t “know” that it’s a derived class. That information is held by the type.

    So, the type information for Class1 might be slightly larger than the type information for Class2, but instances of those two classes will occupy the same amount of memory.

    When all’s said, using Class1, which inherits from baseClass, is going to cost you a handful of bytes more than using Class2, because you have type information for two classes. But it really is just a few bytes more–whatever the overhead is for the class metadata. It does not cost you anything extra for each class instance.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Imagine a situation, I have PC with two lan cards, one is connected to
Imagine I have an function which goes through one million/billion strings and checks smth
Ok, here is the question. Imagine I have a ModelForm which have only two
We have a set of about two dozen classes that inherit from a base
I have two classes, basically one holds Members and the other Sessions. They are
Let's imagine I have two threads which execute some database-oriented code in thread-specific TransactionScopes
Imagine I have two C# files. The first file, Class1.cs contains namespace CrossReferenceCheckingTest {
I have two classes. One is called Employee and the other EmployeeDetails that has
Imagine you have two tables, with a one to many relationship. For this example,
I have a CI website which contains two application folders, one for the front

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.