I was wondering what would be usage of the in
keyword with ReadOnlyMemory<T>
and ReadOnlySpan<T>
.
void Method(ReadOnlyMemory<int> memory)
{
// Code that modifies memory wont reflect out of this scope.
memory = memory.Slice(3);
}
void Method(in Memory<int> memory)
{
// same thing as the above
memory.Slice(3);
}
void Method(in ReadOnlyMemory<int> memory)
{
// is there any performance gain here or something?
}
Basically using in
or ReadOnly
(Span
/Memory
) isn't similar to const typename &
(C++) ?