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 USer Front Page PHP code of user front page after login <?php include 'settings.php'; ?> <html> <head> <title></title> <style type="text/css"> #container { background: scroll; background-color: #c… Read More
  • Index/User page. sample code <?php include 'settings.php'; ?> <html> <head> <title></title> <style type="text/css"> #container { background: scroll; background-color: #cccfff; border: 2; } #container1 { … Read More
  • HTML code for Dating site HTML code for Dating site <html> <head> <title>Love Dating</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="s… Read More
  • PHP code To upgrade any data with css in it<?php $company = $_POST["company"]; if(isset($_POST['submit'])) { $result = mysql_query("SELECT * FROM detail WHERE company_name=$company");     while($row = mysql_fetch_array($result)) { echo $row['premise_… Read More
  • cSS code for Dating site cSS code for Dating site body { background:url(images/bg.jpg) repeat-x top #cfe1ed; margin:0px; padding:0px; font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#454241; } p{ margin:0px; padding:3px 0… Read More

0 comments:

Post a Comment