Search - Articles
DevASP.NET for ASP.NET, VB.NET, XML and C# (C-Sharp) Developers Tuesday, March 03, 2009
Dev Articles
Search Directory
ASP.NET
VB.Net
C-Sharp
SQL Server
 

Remove key-value pair - check privileges – size and synchronization of the hybrid dictionary collection using HybridDictionary class vb.net - C# .net.

Author: Maliha Atteeq
Download Source Code : 990_hybridDictionary3.zip

In this simple article you will learn that how to remove a key-value pair, check privileges, size, synchronization of the hybrid dictionary collection using HybridDictionary class in vb and C# .net.

 Get privileges:

In order to get the privileges of your hybrid dictionary collection, hybrid dictionary collection class provides us a property named as IsReadOnly. The return type of this property is Boolean. It will return true if your collection is read only and don’t have privileges to write otherwise it will return false if your collection in not just read only.

To demonstrate make a new window application. Drag one button on from.

Now write the following code on Button click event:

C#:

private void btn_preiviliges_Click(object sender, EventArgs e)

        {

            bool temp;

            temp=obj.IsReadOnly;

            if (temp)

            {

                MessageBox.Show("your hybrid dictionary collection is read only");

            }

            else

            {

                MessageBox.Show("your hybrid dictionary collection is not read only");

            }

        }

VB:

Private Sub btn_preiviliges_Click(ByVal sender As Object, ByVal e As EventArgs)

        Dim temp As Boolean

        temp = obj.IsReadOnly

        If temp Then

            MessageBox.Show("your hybrid dictionary collection is read only")

        Else

            MessageBox.Show("your hybrid dictionary collection is not read only")

        End If

    End Sub

 

 

Check size:

In order to check that whether the hybrid dictionary collection has fixed size or not, hybrid dictionary class provides us a property named as IsFixedSize. The return type of this property is Boolean. It will return true if your hybrid dictionary collection has fixed size otherwise it will return false.

To demonstrate make a new window application. Drag one button on from.

Now write the following code on Button click event:

C#:

private void btn_checkSize_Click(object sender, EventArgs e)

        {

            bool temp;

            temp = obj.IsFixedSize;

            if (temp)

            {

                MessageBox.Show("your hybrid dictionary collection has fixed size");

            }

            else

            {

                MessageBox.Show("your hybrid dictionary collection dont have fixed size");

            }

        }

 

VB:

Private Sub btn_checkSize_Click(ByVal sender As Object, ByVal e As EventArgs)

        Dim temp As Boolean

        temp = obj.IsFixedSize

        If temp Then

            MessageBox.Show("your hybrid dictionary collection has fixed size")

        Else

            MessageBox.Show("your hybrid dictionary collection dont have fixed size")

        End If

    End Sub

Check synchronization:

In order to check that whether the hybrid dictionary collection is synchronized or not, hybrid dictionary class provides us a property named as IsSynchronised. The return type of this property is bollean. It will return true if the collection is synchronised otherwise it will return false.

To demonstrate make a new window application. Drag one button on from.

Now write the following code on Button click event:

C#:

private void btn_synchroniz_Click(object sender, EventArgs e)

        {

            bool temp;

            temp = obj.IsSynchronized;

            if (temp)

            {

                MessageBox.Show("your hybrid dictionary collection is synchronized");

            }

            else

            {

                MessageBox.Show("your hybrid dictionary collection is not synchronized");

            }

        }

 

VB:

Private Sub btn_synchroniz_Click(ByVal sender As Object, ByVal e As EventArgs)

        Dim temp As Boolean

        temp = obj.IsSynchronized

        If temp Then

            MessageBox.Show("your hybrid dictionary collection is synchronized")

        Else

            MessageBox.Show("your hybrid dictionary collection is not synchronized")

        End If

    End Sub

Remove a key-value pair:

In order to remove a key-value pair from your hybrid dictionary collection, hybrid dictionary class provides us a function named as remove(). This function takes one argument as a parameter which is the key. The return type of this function is void as it returns nothing.

To demonstrate make a new window application. Drag one button on from.

Now write the following code on Button click event:

C#:

private void btn_remove_Click(object sender, EventArgs e)

        {

            int key;

            key = Convert.ToInt16(txt_key.Text);

            obj.Remove(key);

            MessageBox.Show("the key-value pair is removed from collection having key= "+Convert.ToString(key));

        }

VB:

Private Sub btn_remove_Click(ByVal sender As Object, ByVal e As EventArgs)

        Dim key As Integer

        key = Convert.ToInt16(txt_key.Text)

        obj.Remove(key)

        MessageBox.Show("the key-value pair is removed from collection having key= " & Convert.ToString(key))

    End Sub

Now write the following code on FORM LOAD event:

C#:

private void Form1_Load(object sender, EventArgs e)

        {

            this.Text = "DEVASP HYBRID DICTIONARY APPLICATION";

            obj.Add(1, 10);

            obj.Add(2, 20);

            obj.Add(3, 30);

            obj.Add(4, 40);

            obj.Add(5, 50);

          }

Vb:

Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)

        Me.Text = "DEVASP HYBRID DICTIONARY APPLICATION"

        obj.Add(1, 10)

        obj.Add(2, 20)

        obj.Add(3, 30)

        obj.Add(4, 40)

        obj.Add(5, 50)

    End Sub

This simple article tells that how to remove a key-value pair, check privileges, size, synchronization of the hybrid dictionary collection using HybridDictionary class in vb and C# .net.

   
Add Article Comment:
Name :
Email Address :
   
Comments :
 
   
<< Search value - get count - hash code and type of the hybrid dictionary collection using HybridDictionary class vb.net - C# .net.

Disclaimer - Privacy
© 2002-2017 DevASP.net