How can clear and count a list in C#

Now we are going to learn about clear and count a list in C#.
  • 4478

Introduction

C# does not provide a facility to resize the array in dynamically so we have a facility to increase the size that is called list. we have use the < and > for declare the list this is not symbol of the greater then or less then.
There is a facility to clear a list in c# . here we are disusing that how can count a list clear a list. there is the example below:

Example

class program   
{
static
void Main()
{
List
<bool > list = new List<bool>();
list.Add(true );
list.Add(true);
list.Add(false );
list.Add(true);
list.Add(false );
Console.WriteLine(list.Count);
list.Clear();
Console.WriteLine(list.Count);
Console
.ReadLine();
}
}
}

Output

clearlist.jpg

© 2019 DotNetHeaven. All rights reserved.