
- C# Basic Tutorial
- C# - Home
- C# - Overview
- C# - Environment
- C# - Program Structure
- C# - Basic Syntax
- C# - Data Types
- C# - Type Conversion
- C# - Variables
- C# - Constants
- C# - Operators
- C# - Decision Making
- C# - Loops
- C# - Encapsulation
- C# - Methods
- C# - Nullables
- C# - Arrays
- C# - Strings
- C# - Structure
- C# - Enums
- C# - Classes
- C# - Inheritance
- C# - Polymorphism
- C# - Operator Overloading
- C# - Interfaces
- C# - Namespaces
- C# - Preprocessor Directives
- C# - Regular Expressions
- C# - Exception Handling
- C# - File I/O
- C# Advanced Tutorial
- C# - Attributes
- C# - Reflection
- C# - Properties
- C# - Indexers
- C# - Delegates
- C# - Events
- C# - Collections
- C# - Generics
- C# - Anonymous Methods
- C# - Unsafe Codes
- C# - Multithreading
- C# Useful Resources
- C# - Questions and Answers
- C# - Quick Guide
- C# - Useful Resources
- C# - Discussion
Check if an array is synchronized or not in C#
To check if an array is synchronized or not, the code is as follows −
Example
using System; public class Demo { public static void Main() { string[] products = new string[] { }; Console.WriteLine("One or more planets begin with 'E'? = {0}", Array.Exists(products, ele => ele.StartsWith("E"))); Console.WriteLine("Is the array having fixed size? = " + products.IsFixedSize); Console.WriteLine("Is the array read only? = " + products.IsReadOnly); Console.WriteLine("Is the array synchronized? = " + products.IsSynchronized); } }
Output
This will produce the following output −
One or more planets begin with 'E'? = False Is the array having fixed size? = True Is the array read only? = False Is the array synchronized? = False
Example
Let us see another example −
using System; public class Demo { public static void Main() { String[] strArr1 = new String[3] { "John", "Jacob", "Tim"}; String[] strArr2 = new String[3] { "Tom","Brad","Bradley"}; Console.WriteLine("First String array..."); foreach(string val in strArr1) { Console.WriteLine(val); } Console.WriteLine("Is the 1st array having fixed size? = " + strArr1.IsFixedSize); Console.WriteLine("Is the 1st array read only? = " + strArr1.IsReadOnly); Console.WriteLine("Is the 1st array synchronized? = " + strArr1.IsSynchronized); Console.WriteLine("
Second String array..."); foreach(string val in strArr2) { Console.WriteLine(val); } Console.WriteLine("Is the 2nd array having fixed size? = " + strArr2.IsFixedSize); Console.WriteLine("Is the 2nd array read only? = " + strArr2.IsReadOnly); Console.WriteLine("Is the 2nd array synchronized? = " + strArr2.IsSynchronized); Console.WriteLine("Are both the array objects equal? = "+strArr1.Equals(strArr2)); } }
Output
This will produce the following output −
First String array... John Jacob Tim Is the 1st array having fixed size? = True Is the 1st array read only? = False Is the 1st array synchronized? = False Second String array... Tom Brad Bradley Is the 2nd array having fixed size? = True Is the 2nd array read only? = False Is the 2nd array synchronized? = False Are both the array objects equal? = False
- Related Articles
- Check if an array is read-only or not in C#
- Check if an array is descending, ascending or not sorted in JavaScript
- How to Check if an Array is Empty or Not in Java
- C Program to check if an Array is Palindrome or not
- Swift Program to check if an Array is Palindrome or not
- Check if an Array has fixed size or not in C#
- Check if HybridDictionary is Synchronized in C#
- Check if ListDictionary is synchronized in C#
- Check if StringDictionary is synchronized in C#
- Check if Hashtable is synchronized C#
- Program to check if an Array is Palindrome or not using STL in C++
- C Program to check if an array is palindrome or not using Recursion
- Program to check if an array is sorted or not (Iterative and Recursive) in C
- Check if a given array is pairwise sorted or not in C++
- Check if a SortedList object is synchronized in C#

Advertisements