How to get the number of items in a list

In my program, I took a list, in this list I added the number of elements.

Now I want to know how to get the number of elements in a list and show the number of elements in a text box. when the number of elements is not fixed.

+4
source share
1 answer

Let's say your list is called ListBox1, and the text box is TextBox1. Then you need a code

TextBox1.Text = ListBox1.Items.Count.ToString(); 

Of course, knowing your platform (WinForms, WebForms, Html, etc.) could help in a more accurate answer.

+13
source

All Articles