Showing posts with label Remove. Show all posts
Showing posts with label Remove. Show all posts

19 January 2014

Session Add, Remove, Clear, RemoveAll and Abandon in ASP.NET

Session Add, Remove,  Clear, RemoveAll  and Abandon in ASP.NET

1. Session Add

To add in the Session
For ex
Session.Add("UserID",1);
   or
Session["UserID"]=1;

UserID is Session ID
1 is Session value

2. Session Remove

Session.Remove(“UserID”);
It removes the specific session’s specific key value i.e) It removes the SessionID UserID


3. Session Clear

Session.Clear()
It clears all session value i.e) It clears all the key value pairs stored in the session state collection.

4. Session RemoveAll

Session.RemoveAll();
This Method calls above clear method in its implementation,
public sealed class HttpSessionState : ICollection, IEnumerable
{
   .....
   public void RemoveAll()
   {
       this.Clear();
   }
   .....
}

5. Session Abandon

Session.Abandon() destroy everything in the session. While logout you have to clear everything in session.




20 June 2011

Example for Array list in C# and Binary Search,Sort,Remove,Removeat

ArrayList Class

Implements the IList interface using an array whose size is dynamically increased as required.
The capacity of a ArrayList is the number of elements the ArrayList can hold. As elements are added to an ArrayList, the capacity is automatically increased as
required through reallocation.
//Example for Array list in C# and Binary Search,Sort,Remove,Removeat

using System;
using System.Collections;
public class SamplesArrayList
{

public static void Main()
{

ArrayList myAL = new ArrayList();
//Insert values in arraylist
for (int i = 0; i <= 10; i++)
myAL.Add(i * 2);

// Displays the ArrayList.
Console.WriteLine("The Int32 ArrayList contains the following:");
PrintValues(myAL);

// Locates a specific object that does not exist in the ArrayList.
Object myObject = 4;
FindMyObject(myAL, myObject);

// Locates an object that exists in the ArrayList.
Object myObjectSearch = 11;
FindMyObject(myAL, myObjectSearch);

// Removes the element containing "4".
myAL.Remove(4);

// Removes the element at index 5.
myAL.RemoveAt(5);

// Removes three elements starting at index 4.
myAL.RemoveRange(4, 3);

// Sorts the values of the ArrayList.
myAL.Sort();

//Print the Values
PrintValues(myAL);
}

///
/// Find the value in the array List
///
///
///
public static void FindMyObject(ArrayList myList, Object myObject)
{
//Store the index value of the search value
int myIndex = myList.BinarySearch(myObject);
//Check the index exist or not
if (myIndex < 0)
Console.WriteLine("The object to search for ({0}) is not found.", myObject);
else
Console.WriteLine("The object to search for ({0}) is at index {1}.", myObject, myIndex);
}

///
/// Print the array list
///
///
public static void PrintValues(IEnumerable myList)
{
foreach (Object obj in myList)
Console.Write(" {0}", obj);
Console.WriteLine();
}

}


Consistency level in Azure cosmos db

 Consistency level in Azure cosmos db Azure Cosmos DB offers five well-defined consistency levels to provide developers with the flexibility...