Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is the Count property of Queue class in C#?
Use the Count property to find the count of elements of the Queue class. Set elements like the following declaration −
Queue q = new Queue(); q.Enqueue(1); q.Enqueue(2); q.Enqueue(3); q.Enqueue(4);
Then use the Count property to count the elements −
q.Count
The following is an example showing how to work with Count property in Queue Class −
Example
using System;
using System.Collections;
namespace Demo {
class Program {
static void Main(string[] args) {
Queue q = new Queue();
q.Enqueue(1);
q.Enqueue(2);
q.Enqueue(3);
q.Enqueue(4);
Console.WriteLine("Total elements: {0} ", q.Count);
Console.ReadKey();
}
}
}
Output
Total elements: 4
Advertisements