Create a shallow copy of the Array in CSharp

Description

The following code shows how to create a shallow copy of the Array.

Example


/*w  ww  .  ja  v  a 2 s  .c  o m*/
using System;
using System.Globalization;
public class SamplesArray  {

   public static void Main()  {
      CultureInfo[] arrCI = new CultureInfo[] { new CultureInfo( "ar-SA", false ), 
                             new CultureInfo( "en-US", false ) };

      // Create a clone of the CultureInfo array.
      CultureInfo[] arrCIClone = (CultureInfo[]) arrCI.Clone();
      foreach(CultureInfo c in arrCIClone){
         Console.WriteLine(c);
      }
   }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    Data Types »




C# Data Types
Bool
Byte
Char
Decimal
Double
Float
Integer
Long
Short
String
C# Array
Array Example
Byte Array
C# Standard Data Type Format
BigInteger
Complex
Currency
DateTime
DateTimeOffset
DateTime Format Parse Convert
TimeSpan
TimeZone
Enum
Null
tuple
var