
- 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
How are the methods and properties of Array class in C# useful?
The Array class is the base class for all the arrays in C#. It is defined in the System namespace.
The following are the methods of the Array class in C# −
Sr.No | Method & Description |
---|---|
1 | Clear Sets a range of elements in the Array to zero, to false, or to null, depending on the element type. |
2 | Copy(Array, Array, Int32) Copies a range of elements from an Array starting at the first element and pastes them into another Array starting at the first element. The length is specified as a 32-bit integer. |
3 | CopyTo(Array, Int32) Copies all the elements of the current one-dimensional Array to the specified one-dimensional Array starting at the specified destination Array index. The index is specified as a 32-bit integer. |
4 | GetLength Gets a 32-bit integer that represents the number of elements in the specified dimension of the Array. |
5 | GetLongLength Gets a 64-bit integer that represents the number of elements in the specified dimension of the Array. |
6 | GetLowerBound Gets the lower bound of the specified dimension in the Array. |
7 | GetType Gets the Type of the current instance. (Inherited from Object.) |
8 | GetUpperBound Gets the upper bound of the specified dimension in the Array. |
9 | GetValue(Int32) Gets the value at the specified position in the one-dimensional Array. The index is specified as a 32-bit integer. |
10 | IndexOf(Array, Object) Searches for the specified object and returns the index of the first occurrence within the entire one-dimensional Array. |
11 | Reverse(Array) Reverses the sequence of the elements in the entire one-dimensional Array. |
The following are the properties of the Array class in C#.
Sr.No | Property & Description |
---|---|
1 | IsFixedSize Gets a value indicating whether the Array has a fixed size. |
2 | IsReadOnly Gets a value indicating whether the Array is read-only. |
3 | Length Gets a 32-bit integer that represents the total number of elements in all the dimensions of the Array. |
4 | LongLength Gets a 64-bit integer that represents the total number of elements in all the dimensions of the Array. |
5 | Rank Gets the rank (number of dimensions) of the Array. |
Let us see an example of the Reverse method to reverse the characters in an array of characters and find whether its palindrome or not −
Let us try the complete example. Here, our string is “Level”, which is when reversed gives the same result.
Example
using System; namespace Demo { class Program { static void Main(string[] args) { string string1, rev; string1 = "Level"; char[] ch = string1.ToCharArray(); Array.Reverse(ch); rev = new string(ch); bool b = string1.Equals(rev, StringComparison.OrdinalIgnoreCase); if (b == true) { Console.WriteLine("String " + string1 + " is a Palindrome!"); }else { Console.WriteLine("String " + string1 + " is not a Palindrome!"); } Console.Read(); } } }
- Related Articles
- Useful Methods of Integer Class in Ruby
- What are the methods and properties of the Thread class in C#?
- Useful Methods in Float Class in Ruby
- Useful Methods from Numeric Class in Ruby
- What are the properties of array class in C#?
- What are some of the commonly used methods of the array class in C#?
- What are the differences between class methods and class members in C#?
- What are the important methods of the SQLException class?
- PHP Static Properties and Methods
- Which properties of synthetic fiber make them useful?
- Are the private variables and private methods of a parent class inherited by the child class in Java?
- How to display methods and properties using reflection in C#?
- Properties of the Thread Class
- Methods of the Thread Class
- How to get all properties and methods available for the service in PowerShell?

Advertisements