C# Programming - Structures - Discussion
Discussion Forum : Structures - General Questions (Q.No. 6)
6.
Which of the following statements is correct about the C#.NET code snippet given below?
class Trial
{
int i;
Decimal d;
}
struct Sample
{
private int x;
private Single y;
private Trial z;
}
Sample ss = new Sample();
Discussion:
7 comments Page 1 of 1.
Abhishek said:
7 years ago
Yes, SS will create on stack because struct is value type, and Z will also create on stack because we are creating reference not object.
And all reference stored on the stack and object stored on the heap.
And all reference stored on the stack and object stored on the heap.
Viktor said:
8 years ago
@Ramprasad.
No, it's not true. Z will be created on the stack (its a memory address only). The OBJECT, which is referred by Z gonna be created on heap.
No, it's not true. Z will be created on the stack (its a memory address only). The OBJECT, which is referred by Z gonna be created on heap.
Gopi said:
9 years ago
What is trail means in the above program?
Ramprasad said:
10 years ago
Z will be created on the heap. This is also correct.
Mantu Singh said:
1 decade ago
Structure Class is a value type. It stores the value in Stack. Stack hold value of value type.
John said:
1 decade ago
Stack holds static memory items, Heap holds dynamic memory items. Stack holds value types (known amount of memory required), and also references to reference types (see how that works?) i.e. Objects that are actually stored on the Heap.
Yogita said:
1 decade ago
Can anyone please explain?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers