- 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
How to use the Clone() method of array class in C#?
The Clone() method in C# is used to clone the existing array.
Firstly, set the array to be cloned.
string[] arr = { "Web", "World"};
Now clone the array created above using the array.Clone() method.
string[] arrClone = array.Clone() as string[];
Let us see the complete example.
Example
using System; class Program { static void Main() { string[] arr = { "Web", "World"}; Console.WriteLine(string.Join(",", arr)); string[] arrClone = array.Clone() as string[]; Console.WriteLine(string.Join(",", arrClone)); Console.WriteLine(); } }
- Related Articles
- How to use the Clear method of array class in C#?
- How to use the Copy(, ,) method of array class in C#
- How to use the CopyTo(,) method of array class in C#
- How to use the GetLength method of array class in C#?
- How to use the GetLongLength method of array class in C#?
- How to use the GetLowerBound method of array class in C#
- How to use the GetType method of array class in C#?
- How to use the GetUpperBound method of array class in C#?
- How to use the GetValue() method of array class in C#?
- How to use the IndexOf(,) method of array class in C#?
- How to use the Reverse() method of array class in C#
- How to use the SetValue(,) method of array class in C#?
- How to use the Sort() method of array class in C#?
- How to use the Compare method of the string class in C#?
- How to use WriteLine() method of Console class in C#?

Advertisements