Wednesday, February 12, 2014

Stack In C#(How it works)

using System;
using System.Collections; // we need to add this reference to use Files and Directory information
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Stacks
{
    class Program
    {
        static void Main(string[] args)
        {
            Stack myStack = new Stack();

            myStack.Push("item 1");
            myStack.Push("item 2");
            myStack.Push("item 3");
            Console.WriteLine("{0} Items on the stack", myStack.Count);

            // Have a peek at the top item
            Console.WriteLine("{0}", myStack.Peek());

            myStack.Pop(); // pops "item 3" off the top
            // now "item 2" is the top item
            Console.WriteLine("{0}", myStack.Peek());

            myStack.Clear(); // get rid of everything
            Console.WriteLine("{0} Items on the stack", myStack.Count);

            Console.ReadLine();
        }
    }
}

Related Posts:

  • PHP code to View comments PHP code to View comments in web site <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> &l… Read More
  • Login Form Code in PHP<?php include "settings.php"; ?> <html> <head> <title>Login System</title> <style type="text/css"> #container { position: relative; width: 500px; margin: 0px auto; height… Read More
  • LOGIN Form Login form with css and Database connectivity and sql file Free download the zip folder  :click to download … Read More
  • Simplest jQuery Slideshow Code Simplest jQuery Slideshow Code <html "> <head> <title>Simplest jQuery Slideshow</title> <style> body {font-family:Arial, Helvetica, sans-serif; font-size:12px;} .fadein {  posit… Read More
  • PHP login Form with css  Php Login form with css and data base connectivity <?php include "settings.php"; ?> <html> <head> <title>Login System</title> <style type="text/css"> #container { positio… Read More

0 comments:

Post a Comment