- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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
Check if the ArrayList has a fixed size in C#
To check if the ArrayList has a fixed size, the code is as follows −
Example
using System; using System.Collections; public class Demo { public static void Main(String[] args) { ArrayList list1 = new ArrayList(); list1.Add("One"); list1.Add("Two"); list1.Add("Three"); list1.Add("Four"); list1.Add("Five"); Console.WriteLine("Elements in ArrayList..."); foreach (string res in list1) { Console.WriteLine(res); } ArrayList list = ArrayList.Synchronized(list1); Console.WriteLine("Is ArrayList synchronized? = "+list.IsSynchronized); Console.WriteLine("Is ArrayList have a fixed size? = "+list.IsFixedSize); } }
Output
This will produce the following output −
Elements in ArrayList... One Two Three Four Five Is ArrayList synchronized? = True Is ArrayList have a fixed size? = False
Example
Let us see another example −
using System; using System.Collections; public class Demo { public static void Main(String[] args) { ArrayList list1 = new ArrayList(); list1.Add("ABC"); list1.Add("BCD"); list1.Add("CDE"); list1.Add("DEF"); list1.Add("EFG"); list1.Add("GHI"); list1.Add("HIJ"); list1.Add("IJK"); list1.Add("JKL"); list1.Add("KLM"); Console.WriteLine("Elements in ArrayList..."); foreach (string res in list1) { Console.WriteLine(res); } ArrayList list = ArrayList.Synchronized(list1); Console.WriteLine("Is ArrayList synchronized? = "+list.IsSynchronized); ArrayList list2 = ArrayList.FixedSize(list1); Console.WriteLine("Is ArrayList have a fixed size? = "+list2.IsFixedSize); } }
Output
This will produce the following output −
Elements in ArrayList... ABC BCD CDE DEF EFG GHI HIJ IJK JKL KLM Is ArrayList synchronized? = True Is ArrayList have a fixed size? = True
- Related Articles
- Check if Hashtable has a fixed size in C#
- Check if ListDictionary has a fixed size in C#
- Check if HybridDictionary has fixed size in C#
- Check if a SortedList object has a fixed size in C#
- Check if an Array has fixed size or not in C#
- Check if the ArrayList is read-only in C#
- Check if two ArrayList objects are equal in C#
- Check if ArrayList is Synchronized (thread safe) in C#
- Check if a number has two adjacent set bits in C++
- Check if a Java ArrayList contains a given item or not
- Check if a Binary Tree (not BST) has duplicate value in C++
- Check If a String Contains All Binary Codes of Size K in C++
- Check if a number has bits in alternate pattern - Set 1 in C++
- C++ Program to check if a string has been seen before
- Get the size of an ArrayList in Java

Advertisements