c# array.clone
C#
using System;
using System.Globalization;
public class SamplesArray {
public static void Main() {
// Create and initialize a new CultureInfo array.
CultureInfo ci0 = new CultureInfo( "ar-SA", false );
CultureInfo ci1 = new CultureInfo( "en-US", false );
CultureInfo ci2 = new CultureInfo( "fr-FR", false );
CultureInfo ci3 = new CultureInfo( "ja-JP", false );
CultureInfo[] arrCI = new CultureInfo[] { ci0, ci1, ci2, ci3 };
// Create a clone of the CultureInfo array.
CultureInfo[] arrCIClone = (CultureInfo[]) arrCI.Clone();
// Replace an element in the clone array.
CultureInfo ci4 = new CultureInfo( "th-TH", false );
arrCIClone[0] = ci4;
// Display the contents of the original array.
Console.WriteLine( "The original array contains the following values:" );
PrintIndexAndValues( arrCI );
// Display the contents of the clone array.
Console.WriteLine( "The clone array contains the following values:" );
PrintIndexAndValues( arrCIClone );
// Display the DateTimeFormatInfo.DateSeparator for the fourth element in both arrays.
Console.WriteLine( "Before changes to the clone:" );
Console.WriteLine( " Original: The DateTimeFormatInfo.DateSeparator for {0} is {1}.", arrCI[3].Name, arrCI[3].DateTimeFormat.DateSeparator );
Console.WriteLine( " Clone: The DateTimeFormatInfo.DateSeparator for {0} is {1}.", arrCIClone[3].Name, arrCIClone[3].DateTimeFormat.DateSeparator );
// Replace the DateTimeFormatInfo.DateSeparator for the fourth element in the clone array.
arrCIClone[3].DateTimeFormat.DateSeparator = "-";
// Display the DateTimeFormatInfo.DateSeparator for the fourth element in both arrays.
Console.WriteLine( "After changes to the clone:" );
Console.WriteLine( " Original: The DateTimeFormatInfo.DateSeparator for {0} is {1}.", arrCI[3].Name, arrCI[3].DateTimeFormat.DateSeparator );
Console.WriteLine( " Clone: The DateTimeFormatInfo.DateSeparator for {0} is {1}.", arrCIClone[3].Name, arrCIClone[3].DateTimeFormat.DateSeparator );
}
public static void PrintIndexAndValues( Array myArray ) {
for ( int i = myArray.GetLowerBound(0); i <= myArray.GetUpperBound(0); i++ )
Console.WriteLine( "\t[{0}]:\t{1}", i, myArray.GetValue( i ) );
}
}
/*
This code produces the following output.
The original array contains the following values:
[0]: ar-SA
[1]: en-US
[2]: fr-FR
[3]: ja-JP
The clone array contains the following values:
[0]: th-TH
[1]: en-US
[2]: fr-FR
[3]: ja-JP
Before changes to the clone:
Original: The DateTimeFormatInfo.DateSeparator for ja-JP is /.
Clone: The DateTimeFormatInfo.DateSeparator for ja-JP is /.
After changes to the clone:
Original: The DateTimeFormatInfo.DateSeparator for ja-JP is -.
Clone: The DateTimeFormatInfo.DateSeparator for ja-JP is -.
*/
Also in C#:
- Title
- devexpress objectspace to session
- Category
- C#
- Title
- solid principles c#
- Category
- C#
- Title
- c# enum default
- Category
- C#
- Title
- select a whole row out of a 2d array C#
- Category
- C#
- Title
- convert string to boolean c#
- Category
- C#
- Title
- c# make request to rest api
- Category
- C#
- Title
- computer
- Category
- C#
- Title
- debug.log
- Category
- C#
- Title
- eventos c#
- Category
- C#
- Title
- c# check if type implements interface
- Category
- C#
- Title
- How to solve error in ExecuteNonQuery() in asp.net
- Category
- C#
- Title
- c# resize bitmap
- Category
- C#
- Title
- use newtonsoft json to clone object
- Category
- C#
- Title
- what type of variable is true or false in c#
- Category
- C#
- Title
- csharp datetime string format
- Category
- C#
- Title
- wpf binding object get value
- Category
- C#
- Title
- c# convert list to string
- Category
- C#
- Title
- unity get child
- Category
- C#
- Title
- unity instantiate vector3
- Category
- C#
- Title
- unity coroutine
- Category
- C#
- Title
- set label position winforms
- Category
- C#
- Title
- unity deactivate scripts in list
- Category
- C#
- Title
- how to get component in unity c#
- Category
- C#
- Title
- image filter
- Category
- C#
- Title
- c# if statement
- Category
- C#
- Title
- c# remove last character from string
- Category
- C#
- Title
- c# generate random number
- Category
- C#
- Title
- autoresetevent
- Category
- C#
- Title
- c# string code ascii
- Category
- C#
- Title
- c# input
- Category
- C#
- Title
- c# MD5.Create returning nul
- Category
- C#
- Title
- unity connect to firebase
- Category
- C#
- Title
- c# get index of item in list
- Category
- C#
- Title
- c# singleton
- Category
- C#
- Title
- bulk update in c# using jquery datatble
- Category
- C#
- Title
- c# float to string
- Category
- C#
- Title
- how to add to a list c#
- Category
- C#
- Title
- parsing object from text file c#
- Category
- C#
- Title
- pop up element from specific index in array
- Category
- C#
- Title
- How to search for a string from readline in c#
- Category
- C#
- Title
- get set c#
- Category
- C#
- Title
- displayname c#
- Category
- C#
- Title
- input get button uibutton
- Category
- C#
- Title
- c# request run as administrator
- Category
- C#
- Title
- find gameobject with tag
- Category
- C#
- Title
- C# get all child classes of a class
- Category
- C#
- Title
- flip boolean c#
- Category
- C#
- Title
- isprime c#
- Category
- C#
- Title
- c# index in select
- Category
- C#
- Title
- go right unity
- Category
- C#
- Title
- jumping with character controller unity
- Category
- C#
- Title
- page parent wpf
- Category
- C#
- Title
- html hidden text
- Category
- C#
- Title
- c# replace string case insensitive
- Category
- C#
- Title
- array syntax c#
- Category
- C#
- Title
- asp.net render control to string
- Category
- C#
- Title
- how to mock abstract httpcontext using moq .net core
- Category
- C#
- Title
- c# check if argument null
- Category
- C#
- Title
- how to use variables in c#
- Category
- C#
- Title
- C# save pdf stream to file
- Category
- C#
- Title
- c# get country code
- Category
- C#
- Title
- percentage in c#
- Category
- C#
- Title
- enums as numbers c#
- Category
- C#
- Title
- null coalesce ternary c#
- Category
- C#
- Title
- new command - latex
- Category
- C#
- Title
- how to populate listbox using list<t> c#
- Category
- C#
- Title
- c# create new thread
- Category
- C#
- Title
- unity accessing 2d pointlight from c# script
- Category
- C#
- Title
- unity detect any key
- Category
- C#
- Title
- abstract class c#
- Category
- C#
- Title
- compile in one single exe c#
- Category
- C#
- Title
- sum of digits in c#
- Category
- C#
- Title
- how to edit a c# list
- Category
- C#
- Title
- how to get specific length of row in matrix c#
- Category
- C#
- Title
- object escape player unity
- Category
- C#
- Title
- unity main texture not working
- Category
- C#
- Title
- c# shorten an method
- Category
- C#
- Title
- cshtml foreach
- Category
- C#
- Title
- regex in c#
- Category
- C#
- Title
- how to make rb.addforce 2d
- Category
- C#
- Title
- blazor wasm routable page in separate project
- Category
- C#
- Title
- gfortran: declare an array
- Category
- C#
- Title
- c# find element by condition
- Category
- C#
- Title
- show double in textbox c#
- Category
- C#
- Title
- c# class to byte array
- Category
- C#
- Title
- two players one phone unity gamne
- Category
- C#
- Title
- c# join array
- Category
- C#
- Title
- c# clear list items
- Category
- C#
- Title
- c# inotifypropertychanged best practices
- Category
- C#
- Title
- how to remove space between string in c#
- Category
- C#
- Title
- c# double question mark
- Category
- C#
- Title
- c# verify in class exist in list
- Category
- C#
- Title
- c# tuple access
- Category
- C#
- Title
- c# list tuple
- Category
- C#
- Title
- print content of array c#
- Category
- C#
- Title
- sort c#
- Category
- C#
- Title
- .net core authorizationhandlercontext
- Category
- C#
- Title
- c# shorten an definition
- Category
- C#
- Title
- c# calculate difference between two dates in days
- Category
- C#
- Title
- c# select first value from list
- Category
- C#