Код: Выделить всё
interface IMask
{
string GetName();
}
readonly struct StructSource : IMask
{
string IMask.GetName()
{
throw new NotImplementedException();
}
}
Предположим следующий идеальный мир.
Код: Выделить всё
using System.Runtime.CompilerServices;
void UseValue(ref T value) where T : IMask
{
ref IMask ptr = ref Unsafe.As(ref value);
useInterfaceReference(in ptr);
}
void useInterfaceReference(in IMask target)
{
target.GetName();
}
Подробнее здесь: https://stackoverflow.com/questions/787 ... allocating
Мобильная версия