Why are local variables stored in stack?



Why are local variables stored in stack?..

Answer / Shubhangi Pathak

Local variables are stored in the stack because they have a smaller scope than global or static variables. The stack provides fast access to data due to its sequential nature, which makes it suitable for managing data with shorter lifetimes. Additionally, the size of the stack is limited, ensuring that the program does not consume excessive memory.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Sharp Interview Questions

What is a generic class?

1 Answers  


What is a reference type c#?

1 Answers  


Can you create sealed abstract class in c#?

1 Answers  


Explain a MSIL ? Why is it appreciated by all developers?

1 Answers   Siebel,


which datatype i have to use we i need dynamic size.for eg. empname .in first row it have only five chars.but next row it have 100 chars.

3 Answers  


Can you use foreach iteration on arrays in c#?

1 Answers  


Can an interface inherit an interface

1 Answers   Synechron,


What is lock in c#?

1 Answers  


What is the difference between out and ref in c#?

1 Answers  


What is the main purpose of xml?

1 Answers  


What is virtual in c#?

1 Answers  


What is the difference between “dispose” and “finalize” variables in c#?

1 Answers  


Categories