-
Hi, I just tried a few thing with primary constructors. You can't assign a readonly ref struct C1(ref object ptr)
{
public readonly ref object _ptr = ref ptr; // CS9077: Cannot return a parameter by reference 'ptr' through a ref parameter; it can only be returned in a return statement
} But it works well in other scenario:
But I found a workaround, using readonly ref struct C3(ref object ptr)
{
public readonly ref object _ptr = ref Unsafe.AsRef(in ptr); // Workaround
} |
Beta Was this translation helpful? Give feedback.
Answered by
FaustVX
Jul 15, 2023
Replies: 1 comment 1 reply
-
Please file a bug on roslyn. @AlekseyTs fyi. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ok, opened dotnet/roslyn#69055