
- 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
What are some of the commonly used methods of the array class in C#?
The Array class is the base class for all the arrays in C#. It is defined in the System namespace.The most commonly used methods of the array class are −
Sr.No. | Methods & 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. |
Let us see an eample to get the Upperbound as well Lowerbound of an array using Array class methods −
Example
using System; class Program { static void Main() { int[,] arr = new int[3,4]; Console.WriteLine(arr.GetLength(0)); Console.WriteLine(arr.GetLength(1)); // Length Console.WriteLine(arr.Length); Console.WriteLine("Upper Bound: {0}",arr.GetUpperBound(0).ToString()); Console.WriteLine("Lower Bound: {0}",arr.GetLowerBound(0).ToString()); } }
Output
3 4 12 Upper Bound: 2 Lower Bound: 0
- Related Articles
- What are some commonly used skin care tools?
- What are the commonly used methods to auto-generate the .gitignore file?
- What are some rhetorical devices commonly used in English Literature?
- What are the gauges commonly used in production work?
- What are the most commonly used Idioms in English?
- What are the indicators? Name some commonly known indicators.
- What are the important methods of the SQLException class?
- How are the methods and properties of Array class in C# useful?
- What are the methods and properties of the Thread class in C#?
- What are the methods of an array object in JavaScript?
- What are plastics? Name any five commonly used articles made of plastics.
- What are the properties of array class in C#?
- What are some of the important Scientific Libraries used in Lua programming?
- What are the differences between class methods and class members in C#?
- Name two varieties of cloth materials which are commonly used.

Advertisements