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
 

Search value - get count - hash code and type of the hybrid dictionary collection using HybridDictionary class vb.net - C# .net.

Author: Maliha Atteeq
Download Source Code : 989_hybridDictionary2.zip

In this simple article you will learn that how to search a value, get count, hash code, type of the hybrid dictionary collection using HybridDictionary class in vb and C# .net.

 Get count:

In order to get the total key-value pairs in the hybrid dictionary collection, hybrid dictionary class provides us a property known as Count. This property returns an integer depicting the total key-value pair in your collection.

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

        {

            int count;

            count=obj.Count;

            MessageBox.Show("total key-value pairs are "+Convert.ToString(count));

        }

VB:

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

        Dim count As Integer

        count = obj.Count

        MessageBox.Show("total key-value pairs are " & Convert.ToString(count))

    End Sub

Get type:

In order to get type of your collection, hybrid dictionary class provides us a function named as getType(). This function takes no argument as a parameter. Its return type is system.type as it returns the object of class type .

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

        {

            System.Type ob;

            ob = obj.GetType();

            MessageBox.Show("the type of your collection is "+Convert.ToString(ob));

        }

VB:

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

        Dim ob As System.Type

        ob = obj.[GetType]()

        MessageBox.Show("the type of your collection is " & Convert.ToString(ob))

    End Sub

Get Hash Code:

In order to get hash code of your hybrid dictionary collection, hybrid dictionary class provides a function named as getHashcode(). This function takes no argument as a parameter. Its return type is integer depicting the hash code of your collection.

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

        {

            int code;

            code = obj.GetHashCode();

            MessageBox.Show("hash code of your collection is "+Convert.ToString(code));

        }

VB:

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

        Dim code As Integer

        code = obj.GetHashCode()

        MessageBox.Show("hash code of your collection is " & Convert.ToString(code))

    End Sub

Search the value:

In order to search a value in hybrid dictionary collection, hybrid dictionary collection class provides us a function named as contains(). This function takes one argument as a parameter which is the value to be searched. Its return type is Boolean. If the collection contains the specific value it will return true otherwise it will return false if the collection doesn’t contain.

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

        {

            int value;

            bool temp;

            value = Convert.ToInt16(txt_value.Text);

            temp=obj.Contains(value);

            if (temp)

            {

                MessageBox.Show("the given value is present in collection");

            }

            else

            {

                MessageBox.Show("the given value is not present in collection");

            }

        }

 

VB:

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

        Dim value As Integer

        Dim temp As Boolean

        value = Convert.ToInt16(txt_value.Text)

        temp = obj.Contains(value)

        If temp Then

            MessageBox.Show("the given value is present in collection")

        Else

            MessageBox.Show("the given value is not present in collection")

        End If

    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 search a value, get count, hash code, type of the hybrid dictionary collection using HybridDictionary class in vb and C# .net.

   
Add Article Comment:
Name :
Email Address :
   
Comments :
 
   
<< Initialize - add and clear hybrid dictionary collection using HybridDictionary class vb.net - C# .net.

Disclaimer - Privacy
© 2002-2017 DevASP.net