// c の定義SAMPLE_EXPORTvoidSAMPLE_NumberSequence(unsignedchar*bytes,intlength);
[DllImport(DllName,EntryPoint="SAMPLE_NumberSequence")]publicstaticexternvoidSAMPLE_NumberSequence_UseRef(refbytebytes,intlength);
と書いておいて
staticvoidStackSample(){Span<byte>span=stackallocbyte[10];SampleImport.SAMPLE_NumberSequence_UseRef(refspan[0],span.Length);Console.WriteLine(ToString(span));}
ref span[0]
で先頭要素へのリファレンスを渡すことでできた。