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
 

Check privileges – size - synchronization and synchronized root of the list dictionary collection using ListDictionary class vb.net - C# .net.

Author: Maliha Atteeq
Download Source Code : 993_listDictionary3.zip

In this simple article you will learn that how to check privileges, size, synchronization and synchronized root of the list dictionary collection using ListDictionary class in vb and C# .net.

 Get privileges:

In order to get the privileges of your list dictionary collection, list 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_checkPreiviliges_Click(object sender, EventArgs e)

        {

            bool temp;

            temp = obj.IsReadOnly;

            if (temp)

            {

                MessageBox.Show("the list dictionary collection is read only");

            }

            else

            {

                MessageBox.Show("the list 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("the list dictionary collection is read only ")

        Else

            MessageBox.Show(“the list dictionary collection is not read only ")

        End If

    End Sub

 

Check size:

In order to check that whether the list dictionary collection has fixed size or not,list 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_size_Click(object sender, EventArgs e)

        {

            bool temp;

            temp = obj.IsFixedSize;

            if (temp)

            {

                MessageBox.Show("the list dictionary collection has fixed size");

            }

            else

            {

                MessageBox.Show("the list dictionary collection don't 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("the list dictionary collection has fixed size ")

        Else

            MessageBox.Show("the list dictionary collection don't have fixed size ")

        End If

    End Sub

Check synchronization:

In order to check that whether the list dictionary collection is synchronized or not, list 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_synchronize_Click(object sender, EventArgs e)

        {

            bool temp;

            temp = obj.IsSynchronized;

            if (temp)

            {

                MessageBox.Show("the list dictionary collection is synchronized");

            }

            else

            {

                MessageBox.Show("the list 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 list dictionary collection is synchronized")

        Else

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

        End If

    End Sub

Get synchronized root:

In order to get the synchronized root of the list dictionary collection, list dictionary class provides us a property named as SyncRoot. This property returns the object which you use to synchronize the list dictionary collection. The return type of this function is object.

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_syncRoot_Click(object sender, EventArgs e)

        {

            Object ob;

            ob = obj.SyncRoot;

            MessageBox.Show("the object used for syncronization is "+Convert.ToString(ob));

        }

VB:

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

        Dim ob As Object

        ob = obj.SyncRoot

        MessageBox.Show("the object used for syncronization is " + Convert.ToString(ob))

    End Sub

Now write the following code on FORM LOAD event:

C#:

private void Form1_Load(object sender, EventArgs e)

        {

            this.Text = "DEVASP LIST 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 LIST 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 check privileges, size, synchronization and synchronized root of the list dictionary collection using ListDictionary class in vb and C# .net.

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

Disclaimer - Privacy
© 2002-2017 DevASP.net