A tuple whose members are all of an unmanaged type
Any user-defined struct type that contains fields of unmanaged types only.
You can use the unmanaged constraint to specify that a type parameter is a non-pointer, non-nullable unmanaged type.
A constructed struct type that contains fields of unmanaged types only is also unmanaged, as the following example shows:
C#
using System;
publicstruct Coords<T>
{
public T X;
public T Y;
}
publicclassUnmanagedTypes
{
publicstaticvoidMain()
{
DisplaySize<Coords<int>>();
DisplaySize<Coords<double>>();
}
privateunsafestaticvoid DisplaySize<T>() where T : unmanaged
{
Console.WriteLine($"{typeof(T)} is unmanaged and its size is {sizeof(T)} bytes");
}
}
// Output:// Coords`1[System.Int32] is unmanaged and its size is 8 bytes// Coords`1[System.Double] is unmanaged and its size is 16 bytes
A generic struct may be the source of both unmanaged and managed constructed types. The preceding example defines a generic struct Coords<T> and presents the examples of unmanaged constructed types. The example of a managed type is Coords<object>. It's managed because it has the fields of the object type, which is managed. If you want all constructed types to be unmanaged types, use the unmanaged constraint in the definition of a generic struct:
C#
publicstruct Coords<T> where T : unmanaged
{
public T X;
public T Y;
}
ამ შიგთავსის წყაროს მოძიება GitHub-ზე არის შესაძლებელი, სადაც თქვენ ასევე შეგიძლიათ პრობლემების შექმნა და განხილვა და მოთხოვნების გადმოტანა. დამატებითი ინფორმაციისთვის იხილეთ ჩვენი დამხმარე სახელმძღვანელო.
.NET-(ი)ს უკუკავშირი
.NET არის ღია წყაროს პროექტი. აირჩიეთ ბმული უკუკავშირის გასაგზავნად:
შემოუერთდით Meetup სერიას, რათა შექმნათ მასშტაბური AI გადაწყვეტილებები რეალურ სამყაროში გამოყენების შემთხვევებზე დაყრდნობით თანამემამულე დეველოპერებთან და ექსპერტებთან.