CKTIS / C#
managed: referencia práctica
managed: referencia práctica: managed especifica la convención de llamada administrada de un function pointer.
Versión: C# language; verified against C# 14 reference
Sintaxis
managed /* grammar-specific form */managed especifica la convención de llamada administrada de un function pointer.
Úsalo en interop unsafe si el destino es un método administrado con firma compatible.
Una firma incorrecta de function pointer puede comprometer la seguridad del proceso.
Requiere unsafe; las convenciones unmanaged usan un ABI distinto.
El programa completo usa realmente managed; su stdout esperado exacto es 6.
Ejemplos
using System;
using System.Buffers;
using System.Collections.Concurrent;
using System.Collections.Frozen;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.Json;
using System.Text.Json.Nodes;
using System.Text.Json.Serialization;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Channels;
using System.Threading.Tasks;
using Number = System.Int32;
unsafe { delegate* managed<int, int> pointer = &Double; Console.WriteLine(pointer(3)); } static int Double(int value) => value * 2;
Resultado
6
El programa completo usa realmente `managed`; su stdout esperado exacto es `6`.