- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- 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 Item property of ArrayList class in C#?
Use the Item property of ArrayList class to get or set the element at the specified index in the ArrayList.
The Item property is an indexer so you can use it without adding the property name.
In the below example, we have used it like the following statement −
Console.WriteLine("Element {0} is \"{1}\"", 2, arrList[1]);
Let us see the complete example tolearn how to work with Item property.
Example
using System; using System.Collections; class Demo { public static void Main() { ArrayList arrList = new ArrayList(); arrList.Add(45); arrList.Add(78); arrList.Add(88); Console.WriteLine("Total elements: "+arrList.Count); Console.WriteLine("Element {0} is \"{1}\"", 2, arrList[1]); } }
Output
Total elements: 3 Element 2 is "78"
Advertisements
To Continue Learning Please Login
Login with Google