Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

253
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda