First, C# doesn't have "functions"; it has "methods".
What do you mean by "in which type of data structure is the memory allocated for the variable in that function?"
Nota Bene: Just for the record, "LIFO" is an access strategy (Last-In, First-Out),
not a data structure. Normally, one refers to a STACK as a LIFO STACK. But I digress.
The correct answer is, usually, either
- "it depends", or
- "both stack and heap"
Slots for local variables (variables that only exist within the context of a method invocation) are allocated within the stack frame for the duration of the method invocation, which is located in the program stack.
If the variable is a reference type, that slot is a reference to the actual object instance, memory for which will be allocated from the heap when/if it is instantiated.
IF the variable is a value type, that slot is [usually, but not always] the object instance itself . . . but that is not a given. Value types can (and are), if need be, allocated on the heap. In which case, the stack frame slot for the variable is, like a value type, a reference to the instance allocated on the heap.