Manual memory management requires developers to manage the allocation and de-allocation of blocks of memory. It is both time taking and tedious. C# provides automatic memory management so that developers are freed from this burdensome task. In the vast majority of cases, this automatic memory management increases code quality and enhances developer productivity without negatively affecting either expressiveness or performance.
Program:
|
Using System; public class stack { private node first = null ; public bool Empty { Get { Return (first==null); } }
public object Pop() {
if (first==null) throw new Exception("Cannot Pop from an empty stack."); else { object temp=first.Value; first=first.Next; return temp; } } |