Cliquez pour évaluer et commenter
MSDN
MSDN Library
Développement .NET
Versions précédentes
.NET Framework SDK 2.0
Class Library Reference
System
String, classe
Méthodes String
 Clone, méthode
Réduire tout/Développer tout Réduire tout
Cette page est spécifique à
Microsoft Visual Studio 2005/.NET Framework 2.0

D'autres versions sont également disponibles pour :
Bibliothèque de classes .NET Framework
String.Clone, méthode

Retourne une référence à cette instance de String.

Espace de noms : System
Assembly : mscorlib (dans mscorlib.dll)

Visual Basic (Déclaration)
Public Function Clone As Object
Visual Basic (Utilisation)
Dim instance As String
Dim returnValue As Object

returnValue = instance.Clone
C#
public Object Clone ()
C++
public:
virtual Object^ Clone () sealed
J#
public final Object Clone ()
JScript
public final function Clone () : Object

Valeur de retour

Instance de String.

La valeur de retour n'est pas une copie indépendante de cette instance ; il s'agit simplement d'une autre vue des mêmes données. Utilisez la méthode Copy ou CopyTo pour créer un objet String séparé ayant la même valeur que cette instance.

L'exemple simple de code suivant illustre la méthode Clone.

C#
// Create a Unicode String with 5 Greek Alpha characters
String szGreekAlpha = new String('\u0319',5);
// Create a Unicode String with a Greek Omega character
String szGreekOmega = new String(new char [] {'\u03A9','\u03A9','\u03A9'},2,1);

String szGreekLetters = String.Concat(szGreekOmega, szGreekAlpha, szGreekOmega.Clone());

// Examine the result
Console.WriteLine(szGreekLetters);

// The first index of Alpha
int ialpha = szGreekLetters.IndexOf('\u0319');
// The last index of Omega
int iomega = szGreekLetters.LastIndexOf('\u03A9');

Console.WriteLine("The Greek letter Alpha first appears at index " + ialpha +
    " and Omega last appears at index " + iomega + " in this String.");
C++
// Create a Unicode String with 5 Greek Alpha characters
String^ szGreekAlpha = gcnew String( L'\x0319',5 );

// Create a Unicode String with a Greek Omega character
wchar_t charArray5[3] = {L'\x03A9',L'\x03A9',L'\x03A9'};
String^ szGreekOmega = gcnew String( charArray5,2,1 );
String^ szGreekLetters = String::Concat( szGreekOmega, szGreekAlpha, szGreekOmega->Clone() );

// Examine the result
Console::WriteLine( szGreekLetters );

// The first index of Alpha
int ialpha = szGreekLetters->IndexOf( L'\x0319' );

// The last index of Omega
int iomega = szGreekLetters->LastIndexOf( L'\x03A9' );
Console::WriteLine( String::Concat(  "The Greek letter Alpha first appears at index ", Convert::ToString( ialpha ) ) );
Console::WriteLine( String::Concat(  " and Omega last appears at index ", Convert::ToString( iomega ),  " in this String." ) );

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile pour Pocket PC, Windows Mobile pour Smartphone, Windows Server 2003, Windows XP Édition Media Center, Windows XP Professionnel Édition x64, Windows XP SP2, Windows XP Starter Edition

Le .NET Framework ne prend pas en charge toutes les versions de chaque plate-forme. Pour obtenir la liste des versions prises en charge, consultez Configuration requise.

.NET Framework

Prise en charge dans : 2.0, 1.1, 1.0

.NET Compact Framework

Prise en charge dans : 2.0, 1.0
Contenu de la communauté   Qu'est-ce que le Contenu de la communauté ?
Ajouter du contenu RSS  Annotations
Processing
© 2009 Microsoft Corporation. Tous droits réservés. Conditions d'utilisation | Marques | Confidentialité
Page view tracker