-
I wrote several times without success. So I wrote public static ref readonly StreamEntryId Min(in StreamEntryId id1, in StreamEntryId id2)
{
...
return ref (id1.sequenceNumber <= id2.sequenceNumber ? ref id1 : ref id2);
...
} |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 10 replies
-
The public ref int M(ref int x) {
ref int y = ref x;
return ref y;
} |
Beta Was this translation helpful? Give feedback.
-
The first For the first // here here
// ↓ ↓
ref int a = ref expression; or // here
// ↓
ref int Method()
{
// here
// ↓
return ref ...;
} We should use a pair of For the last two If the ternary // No ref keyword
// | requires ref
// | | requires ref
// ↓ ↓ ↓
(condition ? ref a : ref b) = ...; Here // No ref keyword
// ↓
F() |= 42;
// Equivalent to
//ref int i = ref F();
//i |= 42;
ref int F()
{
return ref ...;
} |
Beta Was this translation helpful? Give feedback.
-
Seems it's explained here: https://github.com/dotnet/csharplang/blob/main/proposals/csharp-7.2/conditional-ref.md
|
Beta Was this translation helpful? Give feedback.
Seems it's explained here: https://github.com/dotnet/csharplang/blob/main/proposals/csharp-7.2/conditional-ref.md