I read various articles / pages on this topic and finally came to this article , which led me to confusion!
In this article, he mentioned that Value Types always go where they were declared , by which the author had in mind, the types of values ββcan be either on the stack or on the heap, according to how / where they are declared.
Let me write a code snippet to make myself clearer:
public class Test { int testInt; string testString; } int anInt; string aString; Test testObj; testObj = new Test();
After these lines of code are executed, the memory allocation will look something like this:

The testInt structure is stored on the heap since it was declared in the Test class.
With this example in mind, let's look at the simple Form.cs code where I declare an integer.
using System.Windows.Forms; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } public int anotherInt; } }
My confusion:
In this case, where is anotherInt allocated? Stack or heap? In appearance, I think most of the answers will be "Stack". But isn't this variable declared in a class called Form1 ? So, according to the first code snippet above, shouldn't you be going in a bunch? If so, under what circumstances will the structure be allocated to the stack? Only if it is declared inside a method? But still, would there be a method under the class that should again be stored on the heap?
A lot of questions that I know! But just curious to find out what is happening. Hope my question is clear.