Unsafe.Copy Metod
Definition
Viktigt
En del information gäller för förhandsversionen av en produkt och kan komma att ändras avsevärt innan produkten blir allmänt tillgänglig. Microsoft lämnar inga garantier, uttryckliga eller underförstådda, avseende informationen som visas här.
Överlagringar
| Name | Description |
|---|---|
| Copy<T>(Void*, T) |
Kopierar ett värde av typen |
| Copy<T>(T, Void*) |
Kopierar ett värde av typen |
Copy<T>(Void*, T)
- Källa:
- Unsafe.cs
- Källa:
- Unsafe.cs
- Källa:
- Unsafe.cs
- Källa:
- Unsafe.cs
- Källa:
- Unsafe.cs
Viktigt!
Detta API uppfyller inte CLS.
Kopierar ett värde av typen T till den angivna platsen.
public:
generic <typename T>
static void Copy(void* destination, T % source);
[System.CLSCompliant(false)]
public static void Copy<T>(void* destination, ref readonly T source) where T : allows ref struct;
public static void Copy<T>(void* destination, ref T source);
[System.CLSCompliant(false)]
public static void Copy<T>(void* destination, ref T source);
[System.CLSCompliant(false)]
public static void Copy<T>(void* destination, ref readonly T source);
[<System.CLSCompliant(false)>]
static member Copy : nativeptr<unit> * 'T -> unit
static member Copy : nativeptr<unit> * 'T -> unit
Typparametrar
- T
Vilken typ av värde som ska kopieras.
Parametrar
- destination
- Void*
Platsen som du vill kopiera till.
- source
- T
En referens till det värde som ska kopieras.
- Attribut
Kommentarer
Både destination och source antas vara korrekt justerade för pekare till data av typen T. Mer information om anpassningsantaganden finns i ECMA-335, sek. I.12.6.2 ("Justering").
Den här metoden motsvarar ungefär följande kod.
static void Copy<T>(void* destination, ref T source)
{
T data = source; // dereference source
*(T*)destination = data;
}
Gäller för
Copy<T>(T, Void*)
- Källa:
- Unsafe.cs
- Källa:
- Unsafe.cs
- Källa:
- Unsafe.cs
- Källa:
- Unsafe.cs
- Källa:
- Unsafe.cs
Viktigt!
Detta API uppfyller inte CLS.
Kopierar ett värde av typen T till den angivna platsen.
public:
generic <typename T>
static void Copy(T % destination, void* source);
[System.CLSCompliant(false)]
public static void Copy<T>(ref T destination, void* source) where T : allows ref struct;
public static void Copy<T>(ref T destination, void* source);
[System.CLSCompliant(false)]
public static void Copy<T>(ref T destination, void* source);
[<System.CLSCompliant(false)>]
static member Copy : 'T * nativeptr<unit> -> unit
static member Copy : 'T * nativeptr<unit> -> unit
Typparametrar
- T
Vilken typ av värde som ska kopieras.
Parametrar
- destination
- T
Platsen som du vill kopiera till.
- source
- Void*
En pekare till det värde som ska kopieras.
- Attribut
Kommentarer
Både destination och source antas vara korrekt justerade för pekare till data av typen T. Mer information om anpassningsantaganden finns i ECMA-335, sek. I.12.6.2 ("Justering").
Den här metoden motsvarar ungefär följande kod.
static void Copy<T>(ref T destination, void* source)
{
T data = *(T*)source; // reinterpret cast source as T* and dereference
destination = data;
}