xxxxxxxxxx
/* Stack
* Stack follows the LIFO last in First Out
* It does not have a fixed size and increase according to the elements that have added to it.
* We have stavk in both Syste.Collections nd System.Collections.Generic
* But we recommended to use the generic Stack<T>
* no boxing and unboxing fro generic stack but for the non generic stack you have to us the unvoxing methods
* Stack element can be added or deleted
* heneric stack have specific data types elemnts
*/
//Create a stack
using System.Collections.Generic;
//Declaring a stack
Stack<int> s1 = new Stack<int>();
//Declare using var keyword
var s2 = new Stack<string>();
//Declare and initilze a stack simultaneousley
//You cant do that
//Adding elements to the stack : Push() : Insert the item at the top of the stack
s1.Push(10);
s1.Push(20);
s1.Push(30);
//Here the stacj will be like this 30, 20, 10 : but the 30 added in the last
s2.Push("Subhasis");
s2.Push("Aditi");
//Create a stack from an array
int[] a = new int[] { 4, 5, 6 };
Stack<int> s3 = new Stack<int>(a);
//Looping through stack
foreach(var item in s3)
Console.WriteLine(item);
//Deleting from the stack : Pop()
//The last element which is added to the stack will be deleted when we use the pop method
s3.Pop();
foreach (var i in s3)
Console.WriteLine($"The values after pop methods are : {i}");
/*The values after pop methods are : 5
The values after pop methods are : 4*/
s1.Pop();
foreach (var g in s1)
Console.WriteLine($"The values in s1 after pop() : {g}");
/*The values in s1 after pop() : 20
The values in s1 after pop() : 10*/
//Take a peek at te last element : Peek() : Do not delete the last element just look at that value
Console.WriteLine(s1.Peek());
Console.WriteLine(s2.Peek());
Console.WriteLine(s3.Peek());
/*20
Aditi
5*/
//Count : give the numvber of elements in the stack
Console.WriteLine(s1.Count);
//Contains : check if the element is there or not
Console.WriteLine(s2.Contains("Aditi"));
/*2
True*/
xxxxxxxxxx
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DemoApplication
{
class Program
{
static void Main(string[] args)
{
Stack st = new Stack();
st.Push(1);
st.Push(2);
st.Push(3);
st.Pop();
foreach (Object obj in st)
{
Console.WriteLine(obj);
}
Console.ReadKey();
}
}
}
xxxxxxxxxx
Stack is a special type of collection that stores elements in LIFO style (Last In First Out).
xxxxxxxxxx
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DemoApplication
{
class Program
{
static void Main(string[] args)
{
Stack st = new Stack();
st.Push(1);
st.Push(2);
st.Push(3);
foreach (Object obj in st)
{
Console.WriteLine(obj);
}
Console.WriteLine(); Console.WriteLine();
Console.WriteLine("The number of elements in the stack " +st.Count);
Console.WriteLine("Does the stack contain the elements 3 "+st.Contains(3));
Console.ReadKey();
}
}
}
xxxxxxxxxx
Clear() Removes all objects from the Stack.
Clone() Creates a shallow copy of the Stack.
Contains(Object) Determines whether an element is in the Stack.
CopyTo(Array, Int32) Copies the Stack to an existing one-dimensional Array, starting at the specified array index.
Equals(Object) Determines whether the specified object is equal to the current object.(Inherited from Object)
GetEnumerator() Returns an IEnumerator for the Stack.
GetHashCode() Serves as the default hash function.
GetType() Gets the Type of the current instance.
MemberwiseClone() Creates a shallow copy of the current Object.
Peek() Returns the object at the top of the Stack without removing it
Pop() Removes and returns the object at the top of the Stack.
Push(Object) Inserts an object at the top of the Stack.
Synchronized(Stack) Returns a synchronized (thread safe) wrapper for the Stack.
ToArray() Copies the Stack to a new array.
ToString() Returns a string that represents the current object.
xxxxxxxxxx
sudo mysql
CREATE USER 'admin'@'localhost' IDENTIFIED BY '';
GRANT ALL PRIVILEGES ON *.* TO 'admin'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
sudo nano /etc/phpmyadmin/config.inc.php
$cfg['Servers'][$i]['AllowNoPassword'] = true;
sudo systemctl restart apache2
sudo systemctl stop mysql
sudo systemctl start mysql
sudo systemctl stop apache2
sudo systemctl start apache2