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
 

How to set and get the capacity and count of the sorted list and how we can check that sorted list is read only using “sorted list” class in vb and C# .net.

Author: Maliha Atteeq
Download Source Code : 963_sortedList.zip

In this simple article you will learn that how we can get and set the capacity of the sorted list using “sorted list” class in Vb and c#.net.

 Capacity of the sorted List:

To get the capacity of the sorted list, sorted list class provides us a property named as CAPACITY.

To demonstrate make a window application. Drag one button on the form and press button.

Now write the following code on button click event:

C#

private void button1_Click(object sender, EventArgs e)

        {

            int a=obj.Capacity;

            MessageBox.Show("capacity is"+a.ToString());          

        }

VB:

 

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

        Dim a As Integer = obj.Capacity

        MessageBox.Show("capacity is" & a.ToString())

    End Sub

 

Sorted List Is Read Only:

You can also check that sorted list is read only or you have a access to write in list. For this purpose sorted List class provides us function names as isReadOnly. If the sorted list is read only then it returns true and message box will show true and if it is not read only then it returns false.

To demonstrate second ways make a window application. Drag one button on the form, press button.

Now write the following code on button click event:

C#

private void button3_Click(object sender, EventArgs e)

        {

            bool temp = obj.IsReadOnly;

            MessageBox.Show(temp.ToString());

        }

VB:

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

        Dim temp As Boolean = obj.IsReadOnly

        MessageBox.Show("the sorted list have readonly access" & temp.ToString())

    End Sub

Count of the sorted List:

To get the count of the sorted list, sorted list class provides us a property named as COUNT.

To demonstrate make a window application. Drag one button on the form and press button.

Now write the following code on button click event:

 

C#

private void button2_Click(object sender, EventArgs e)

        {

            int temp = obj.Count;

            MessageBox.Show("count is" + temp.ToString());

        }

 

VB:

private void button2_Click(object sender, EventArgs e)

        {

            int temp = obj.Count;

            MessageBox.Show("count is" + temp.ToString());

        }

 

Now write the following code on FORM LOAD event:

C#

        private void Form1_Load(object sender, EventArgs e)

        {

            this.Text = "DEVASP SORTED LIST APPLICATION";

            obj.Add(0, 10);

            obj.Add(1, 20);

            obj.Add(2, 30);

            obj.Add(3, 40);

            obj.Add(4, 50);

            obj.Add(5, 60);

        }

VB

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

        Me.Text = "DEVASP SORTED LIST APPLICATION"

        obj.Add(0, 10)

        obj.Add(1, 20)

        obj.Add(2, 30)

        obj.Add(3, 40)

        obj.Add(4, 50)

        obj.Add(5, 60)

    End Sub

This simple article tells that how we can get capacity and count of the sorted list and how we can check that list is read only or not  using “sorted list” class in Vb and c#.net.

   
Add Article Comment:
Name :
Email Address :
   
Comments :
 
   
<< How to get the index of the specified value, specified key and key of specified index using “sorted list” class in vb and C# .net.

Disclaimer - Privacy
© 2002-2017 DevASP.net