Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

247
Views
Other than an interview question when would 'readonly ref readonly` be used in C#?

I've just been told that readonly ref readonly is now valid C#, I can clearly see its use as an interview question, but otherwise when is it of real-life use?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

When you have a mutable struct in which you want to have a field ref readonly (a value you get by reference that cannot be modified by the caller) that does not mutate the struct.

You can find quite a good explanation here: "Readonly Ref vs Ref Readonly in C# Struct"

enter image description here

Now, as to "real-life" use cases... that's probably for performance-sensitive code, where copying the struct is too expensive.


Also, it's not really "new", it's possible to do this since C# 7.2: Microsoft Docs | Readonly references

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!