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

  • Home
  • SEARCH
  • 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 7168779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:51:01+00:00 2026-05-28T14:51:01+00:00

I have a class below that as a method with a value type variable.

  • 0

I have a class below that as a method with a value type variable.

Please can some one explain me that when I create the object of the below then then what goes on the stack and what goes on the heap?

I am interested on where the variable in Method1 goes.

class A
{
    public void Method1()
    {
       int i = 10;
    }
}

A obj = new A();
obj.Method1();
  • 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-05-28T14:51:02+00:00Added an answer on May 28, 2026 at 2:51 pm

    You most likely don’t need to know this. To you, it’s important what the runtime does, not how it does it. And the runtime is free to chose any way to implement local variables. For all you know, they could be saved in a file (although doing that doesn’t make much sense).

    If you really want to know, in general, there are several ways how a local variable can be represented in memory:

    1. No representation at all. If the runtime decides the variable can be optimized away, it can do so. This can happen if nothing ever reads from the variable, like in your code.
    2. It can be in a register. If the variable is small enough to fit in a register, and the runtime decides enregistering it is efficient.
    3. It can be on a stack.
    4. It can be part of a class on the heap. This happens to closed over variable in a method with lambdas, iterator blocks and async methods of C# 5.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class that I am using below. And I am using this
I have three model classes that look as below: class Model(models.Model): model = models.CharField(max_length=20,
I have a few tables that I've defined like the below examples: class TableA
I have the below xaml that I am trying to bind to my class.
I have wrote a class (a snippet is below) which have some data members
GetEmployeeDetails() method returns the value of type Employee. I need to display that value
In the method below there are numerous case statements (many have been removed) that
I have an object A1 of type A. I dynamically find that out ,
I have a template class like below. template<int S> class A { private: char
Code below is working well as long as I have class ClassSameAssembly in same

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.